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:
1 | local playerGui = game.Players.LocalPlayer:WaitForChild( "PlayerGui" ) |
2 |
3 | playerGui.BackpackShopGui.Frame.TwoHundred.MouseButton 1 Click:Connect( function (plr) |
4 | if game.Players:FindFirstChild(plr.Name).leaderstats.Money.Value > = 500 then --// Where the error is |
5 | plr.leaderstats.Money.Value = plr.leaderstats.Money.Value - 500 |
6 | plr.HiddenValues.BackpackCapacity.Value = 200 |
7 | end |
8 | 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)