I keep getting the error Players.booloii.PlayerGui.money giver.TextButton.Script:2: attempt to index nil with 'WaitForChild'" when I test the game, the code I have right now is

local Player = game.Players.LocalPlayer local PlayerStats = Player:WaitForChild('leaderstats'):WaitForChild('money')

script.Parent.MouseButton1Click:Connect(function() PlayerStats.Value = PlayerStats.value + 1 end)

Im pretty new to this, so be nice!

5 comments

1

Could you use code blocks? It'd make the code clearer.

0

The only way I can think of that error popping is because the thing you're trying to wait for doesn't actually exist

0

It seems that your script cannot find the player value

0

ok, i see, What is a solution?

0

Hi, this error may be happening for either a typo, or a wrong usage of a value. Make sure that the value in the Player's leaderstats is named money, like how you defined it! Also, is this a LocalScript or a Serverscript? Thanks!