Attempt to index nil with 'WaitForChild' Error

line 4 attempt to index nil with ‘WaitForChild’

while wait(.1) do
	if game.Players.LocalPlayer.PlayerGui.ActionBarScreenGui.ActionBar:FindFirstChild("RoactTree") then
		wait(.1)
		game.Players.LocalPlayer.PlayerGui:WaitForChild("ActionBarScreenGui",1):WaitForChild("ActionBar",1):WaitForChild("RoactTree",1):WaitForChild("3",1):WaitForChild("Minigame",1):WaitForChild("Marker",1).Position = game.Players.LocalPlayer.PlayerGui:WaitForChild("ActionBarScreenGui",1):WaitForChild("ActionBar",1):WaitForChild("RoactTree",1):WaitForChild("3",1):WaitForChild("Minigame",1):WaitForChild("FishZone",1).Position
		wait(.1)
	end
end
1 Like

When one WaitForChild fails, the others won’t work. Remove the 2nd parameter from WaitForChild.

I added the second parameter because it wasn’t working before without it.

Is it a local script or script?

It is a localscript (30 letter requirement)

Where do you have the localscript?

StarterGui (LocalPlayer.PlayerGui)

Well then why go into the PlayerGui, when you can access it by doing script.Parent.

added more if findfirstchild statements and it worked

1 Like

Mark your message as a solution for other people.