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

Attempt to index nil with 'Humanoid'?? (SLOVED BY ME)

I made this basic script and it keeps saying Attempt to index nil with 'Humanoid' Help please

game.Players.PlayerAdded:Connect(function(plr)
	plr.Character.Humanoid.Health = 0
end)

2 answers

✓ Accepted answer

All I had to do was this:

game.Players.PlayerAdded:Connect(function(plr) wait(0.01) -- Add this plr.Character.Humanoid.Health = 0 end)

1 comment

0

Why not plr.Character:WaitForChild("Humanoid").Health = 0? It will yield until Humanoid exists

When you try to find Humanoid you need to wait till the players connect and load. So yea adding a wait would fix the problem because scripts load first.

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