I keep getting this error : Players.SpoostyGuy.PlayerGui.ScreenGui.Shop.ImageButton.Script:5: bad argument #2 (string expected, got nil)
my code:
script.Parent.MouseButton1Click:Connect(function(plr) local playerTouch = game.Players[plr] if playerTouch.leaderstats.Coins.Value >= 60 then print("Bought!") playerTouch.leaderstats.Coins.Value = playerTouch.leaderstats.Coins.Value -60 else print("Not ENought Money!!") end end) pcall(function(msg) warn(msg) end)
Also, I am using a DataStore and the leaderboard does exist
Line 5 is fine but Line 2 is the problem
Help would be appreciated
If is a LocalScript (it should be as you are manipulating UI), you could reference the player as local player = game.Players.LocalPlayer
and fire a RemoteEvent
to update leaderstats server-side.
MouseButton1Click does not have the player as argument, it has nothing. You can check that in the Object Browser in studio inside "ImageButton"