Hi there! I've been working on some code for a backpack shop and it's not working. It's just not wanting to detect how much cash a player has. I got this output from the console
Argument 1 missing or nil
The code:
local playerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui") playerGui.BackpackShopGui.Frame.TwoHundred.MouseButton1Click:Connect(function(plr) if game.Players:FindFirstChild(plr.Name).leaderstats.Money.Value >= 500 then --// Where the error is plr.leaderstats.Money.Value = plr.leaderstats.Money.Value - 500 plr.HiddenValues.BackpackCapacity.Value = 200 end end)
There are no arguments passed into MouseButton1Click
you need to use game.Players.LocalPlayer
and if this is a ServerScript
it needs to be a LocalScript
since GUI manipulation is best done on the Client-Side
Also, If you are making a Shop Gui use Remotes (Most likely RemoteFunction
s)