--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


