game.Players.PlayerAdded:Connect(function(player)
while wait() do if player.Character.Humanoid == nil then wait() end end
player.Character.Humanoid.Name = "humanoider"
end)
✓ ANSWER ACCEPTED
Why am i getting "attempt to index humanoid with nil error" when i run this script?
2 answers
✓ Accepted answer
Use Roblox’s way of finding the character and then use :WaitForChild to wait for the humanoid to load.
game.Players.PlayerAdded:Connect(function(player)
local char = player.Character or player.CharacterAdded:Wait() -- waits for the character to be added
local hum = char:WaitForChild(“Humanoid”) -- waits for the humanoid to be added
hum.Name = "humanoider"
end)
2 comments
0
Change the quotation marks because my keyboard is bad.
0
Pro tip: don't use the international keyboard layout
Simple error here. Here's the fixed code:
Edit: Fixed code lol
game.Players.PlayerAdded:Connect(function(player)
while wait() do if player.Character:WaitForChild("Humanoid") ~= nil then wait() end end
player.Character.Humanoid.Name = "humanoider"
print(player.Character.Humanoid.Name)
end)
Explanation:
You were making sure the humanoid is nil instead of making sure it isn't nil
I changed == to ~=
== is Equals
~= is not equals
3 comments
0
Lol, i saw that too.
0
I don't think you solved the problem
0
That would still error, because character is nil.
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
I am trying to change the name of the Humanoid when a player loads in, but it just gives me the error message. I tried adding the wait function in to wait until Humanoid existed, but that still gives me errors
These type of errors are very easy to debug. Just follow what the output says and do as it says. If there are no errors then use the print function..
Add this under line 1: local Character = player.CharacterAdded:Connect(function() end)