I am trying to make a SurfaceGui ScrollingFrame Shop, and this script tell's me there is a error between 12 and 23(Between MouseButton1Click
and end
. Can anyone tell me how to fix the error?
gather = game.ServerStorage.GearStorage:GetChildren() scroll = script.Parent.ScrollingFrame player = script.Parent.Parent.Parent for i,v in pairs(gather) do local frame = script.Template:Clone() frame.Name = v.Value frame.Parent = scroll frame.Position = frame.Position + UDim2.new(0,0,0,35*i) frame.ItemName.Text = v.Value.." | "..v.Price.Value frame.Purchase.MouseButton1Click:connect(function(c) if player.globalstats.Points.Value < v.Price.Value then print(player.Name.." can not afford "..v.Value.."") else player.globalstats.Points.Value = player.globalstats.Points.Value - v.Price.Value local tool = v.Tool:Clone() tool.Parent = player.Backpack tool.Name = v.Value end end end)
You have your parenthesis for closing the event connection on line 12 in the wrong place. You should have the closing parenthesis after the second to last end of your script. You are putting it on the last end where the for loop ends.
Overall, your script should look like this:
gather = game.ServerStorage.GearStorage:GetChildren() scroll = script.Parent.ScrollingFrame player = script.Parent.Parent.Parent for i,v in pairs(gather) do local frame = script.Template:Clone() frame.Name = v.Value frame.Parent = scroll frame.Position = frame.Position + UDim2.new(0,0,0,35*i) frame.ItemName.Text = v.Value.." | "..v.Price.Value frame.Purchase.MouseButton1Click:connect(function(c) if player.globalstats.Points.Value < v.Price.Value then print(player.Name.." can not afford "..v.Value.."") else player.globalstats.Points.Value = player.globalstats.Points.Value - v.Price.Value local tool = v.Tool:Clone() tool.Parent = player.Backpack tool.Name = v.Value end end) --Closing parenthesis here to close the event connection on line 12. end
I hope my answer helped you. If it did, be sure to accept it.