shop=game.ServerStorage:findFirstChild(script.Parent.Name)gui=script.Parent.CenterFrame.Shop gui.Header.Text=script.Parent.Name items=shop:GetChildren()xv=0 yv=0 for f,S in pairs(items)do if S.className=="\077\111\100\101\108"then local f=gui.Items.BaseButton:clone()f.Parent=gui.Items f.Name=S.Name f.Image="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061"..S.DecalID.Value f.Position=UDim2.new(0,xv*80,0,yv*80)xv=xv+1 if xv==4 then xv=0 yv=yv+1 end local m=S.ItemDesc:clone()m.Parent=f local x=S.ItemCost:clone()x.Parent=f f.Visible=true end end script.Parent.CenterFrame:TweenPosition(UDim2.new(.5,0,.5,0),"\079\117\116","\081\117\097\100",.2,true)
--once someone talks to the shopkeeper, the GUI will be cloned to the player, and this script will be cloned to the GUI and then enabled to load all the items

shop = game.ServerStorage:findFirstChild(script.Parent.Name)
gui = script.Parent.CenterFrame.Shop

gui.Header.Text = script.Parent.Name

items = shop:GetChildren()

xv = 0
yv = 0

for i, v in pairs(items) do
	if v.className == "Model" then
		local button = gui.Items.BaseButton:clone() --make new button for each item
		button.Parent = gui.Items
		button.Name = v.Name
		button.Image = "http://www.roblox.com/asset/?id=" .. v.DecalID.Value
		button.Position = UDim2.new(0, xv * 80, 0, yv * 80)
		xv = xv + 1
		if xv == 4 then
			xv = 0
			yv = yv + 1
		end
		local desc = v.ItemDesc:clone() --place the item desc into the button
		desc.Parent = button
		local cost = v.ItemCost:clone()
		cost.Parent = button
		button.Visible = true
	end
end

script.Parent.CenterFrame:TweenPosition(UDim2.new(0.5, 0, 0.5, 0), "Out", "Quad", 0.2, true)
