I am trying to make a script where it includes the humanoid. I made it as a local "local humanoid = player:WaitForChild("Humanoid")". Player is a local = game.Players.LocalPlayer. What am I doing wrong
✓ ANSWER ACCEPTED
How do I fix "attempt to index nil with WaitForChild"?
1 answer
✓ Accepted answer
Yeah, you're trying to get the humanoid from the player when it's a child of the character. Also, make sure this is a localscript as game.Players.LocalPlayer doesn't work on the server.
local player = game.Players.LocalPlayer
local character = player.Character
if character then --You want to make sure the player currently has a character
local humanoid = character:FindFirstChild("Humanoid")
--It's better to use findfirstchild so it doesn't return an error if it's not found
end
1 comment
0
It is a local script. Thank you, I figured that a few minutes later. And thanks for telling me about the one to find the character.
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
You are trying to find the Humanoid from the Player. The Humanoid is located in the Player's Character, so since there is no Humanoid located in the player, it will return nil. Just change it to player.Character:FindFirstChild("Humanoid") and it will work.
Looks like that's a server script