Nil "WaitForChild"

Hey, Fellow Developers I’m having trouble understanding what the output means by “nil WaitForChild”

local Tool = script.Parent
local Player = game.Players.LocalPlayer
local PlayerGui = Player:WaitForChild(“PlayerGui”) - this is where I’m having a problem
local Light = true
local ToolGui = Tool.ToolGui

Tool.Activated:Connect(function()
ToolGui.Parent = PlayerGui
if Light == true then
script.Parent.Light.PointLight.Enabled = false
script.Parent.Light.PointLight1.Enabled = false
script.Parent.Union.ParticleEmitter.Enabled = false
script.Parent.Click:Play()
Light = false
else
script.Parent.Light.PointLight.Enabled = true
script.Parent.Light.PointLight1.Enabled = true
script.Parent.Union.ParticleEmitter.Enabled = true
script.Parent.Click:Play()
Light = true
end
end)

1 Like

Hi!
Are you running this script server-sided or on client side using a LocalScript?

If you are running this server-side, you can’t get the LocalPlayer like this, because there is no LocalPlayer on the server side.

2 Likes

Oh lol I didn’t realize Thankyou