I am trying to make a SurfaceGui shop that gets all items in a Folder, clones the frame and changes the frame.ItemName(TextLabel).Text to the name of it. But for some reason I can't get this script to work.
local sp = script.Parent
local folder = sp.ScrollingFrame
local player = script.Parent.Parent.Parent.Parent
function refresh()
folder:ClearAllChildren()
for _,item in pairs(game.ServerStorage.ShopItems:GetChildren()) do
local frame = script.Frame:Clone()
frame.Parent = folder
frame.ItemName.Text = item.Name " : "..item.Price.Value..""
frame.Name = item.Name
frame.Purchase.MouseButton1Click:connect(function(c)
if player:FindFirstChild("globalstats").Points.Value < item.Price.Value
then
return false
else
player:FindFirstChild("globalstats").Points.Value = player:FindFirstChild("globalstats").Points.Value - item.Price.Value
local itemt = item.Tool:Clone()
itemt.Parent = player.Backpack
itemt.Name = item.Name
end
end)
end
end
game.Players.PlayerAdded:connect(function(p)
wait(1)
refresh()
end)
Output show's no error's, can anyone tell me why it won't work?

6 comments
Remove line 4 and try it.
Nope, still won't work.
Try removing the argument "c" on line 12.
xJasonn: Don't give speculative advice as comments. Submit an answer if you have a solution.
Have you done any debugging? Have you checked that
refreshis in fact called when a new player joins by seeing aprinthappen?Still does not work.