Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My Output says :WaitForChild is nil and I dont understand why?

Asked by 3 years ago

This is what the output said: 09:54:33.332 - Players.tyorange09.PlayerGui.ScreenGui.StoneShardValue.Script:2: attempt to index nil with 'WaitForChild'

0
Here is the code: local player = game.Players.LocalPlayer local Ptats = player:WaitForChild("Pstats") local stone = Ptats:WaitForChild("Stone") local text = script.Parent text.Text = "Stone: "..stone.Value stone:GetPropertyChangedSignal("Value"):Connect(function() text.Text = "Stone: "..stone.Value end) tyorange09 4 — 3y

1 answer

Log in to vote
0
Answered by
R_alatch 394 Moderation Voter
3 years ago
Edited 3 years ago

The issue here is that you are using a Script and not a LocalScript. Simply copy your code and put it inside a LocalScript and your code should work fine. The reason a LocalScript is needed is because regular scripts cannot access the LocalPlayer, which is why you get the error that player is nil.

0
Thaanks a million! SemblanceOfSense 0 — 3y
Ad

Answer this question