Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Index Nil error with waitforchild can anyone help?

local player = game.Players.LocalPlayer
local leaderstats = player:WaitForChild("leaderstats")

leaderstats.Views.Changed:Connect(function()
	script.Parent.Text = leaderstats.Views.Value
end)

ERROR:Players.Not_Prototype.PlayerGui.ScreenGui.Counter.Numbers.Script:2: attempt to index nil with 'WaitForChild'

Line:2

1 comment

0

is this a server script? If so, switch it to local as LocalPlayer is only exists on the client

1 answer

✓ Accepted answer

Switch your script to a Localscript. That will solve your problem.

This discussion is preserved as it was. New answers, comments, and votes are closed.