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

Index Nil error with waitforchild can anyone help?

Asked by 3 years ago
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

0
is this a server script? If so, switch it to local as LocalPlayer is only exists on the client imKirda 4491 — 3y

1 answer

Log in to vote
2
Answered by 3 years ago

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

Ad

Answer this question