Attempt index nil with :WaitForChild()

Whenever I join the game it makes this error of “attempt to index nil with WaitForChild()”, I have looked at other posts put I’m still puzzled

local Player = game:GetService("Players").LocalPlayer
local GunCursor = Player:WaitForChild("PlayerGui"):WaitForChild("GunUI"):WaitForChild("Cursor")

Any help would be appreciated

Is it a localscript or script? if it is from the server it will always give nil.

Oh my gosh, I have noticed the error now, I have done it in a normal script when I was meant to put it as a Local, I do apologise.

Thank you ever so much!

LocalPlayer is always nil on server, use a LocalScript unless you have a specific reason to.