How do you change a Player's Humanoids name?

Hello, I am making a script that changes the player’s Humanoid’s name. The problem is, it won’t change it for me.

And I am getting the error 16:06:56.442 - ServerScriptService.Script:2: attempt to index nil with ‘Humanoid’

I can’t find anything online so I decided to post here.

game.Players.PlayerAdded:Connect(function(Player)
	Player.Character.Humanoid.Name = "PlayerHuman"
end)

PlayerAdded fires when a player joins the server; however it does not guarantee the Character will have been loaded.

Listen for CharacterAdded:

player.CharacterAdded:Connect(function(character)
    local humanoid = character:WaitForChild("Humanoid")
    humanoid.Name = "PlayerHuman"
end)

but why rename a humanoid :thinking:

1 Like

but why rename a humanoid :thinking:

It’s so the NPC’s don’t confuse the Players with other NPC’s

when I do that I get the error

16:15:24.586 - player is not a valid member of DataModel “GrassyHillsMap”

You are already listening for PlayerAdded. So just put the code I gave you within the PlayerAdded event listener

1 Like

even when I do that it gives the error

That’s a really weird error. I’m not quite sure of why you are getting that error to be honest. As @sjr04 said, you can just use the CharacterAdded() event. It’s the simplest way. Just do this:

game.Players.PlayerAdded:Connect(function(Player)
   Player.CharacterAdded:Connect(function(Character)
      Character:WaitForChild("Humanoid").Name = "PlayerHuman"
   end)
 end)
1 Like

You don’t need to change anything to not confuse NPC’s, you can use this single line to fix that.

--I'm assuming that you have your variables already done.

if Humanoid and UpperTorso and v ~= script.Parent then --I'm assuming the game is R15 
--Continue your code

If you need more help, just reply to this.

1 Like
game.Players.PlayerAdded:Connect(function(Player)
    Player.CharacterAppearanceLoaded:Connect(function(Character)
        Character.Humanoid.Name = "PlayerHuman"
    end)
end)

Haven’t tested it but it should work.

Also no idea why you want to just change the name.
Maybe you mean the DisplayName?
Changing the name doesn’t change anything, you wanna change the DisplayName.

game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
Character:WaitForChild(“Humanoid”).DisplayName = “PlayerHuman”
end)
end)

Sorry AndrioidBoyz, I yoinked your code for the example.

1 Like

Alright, there’s a script I have that makes an NPC rotate towards the nearest Humanoid, but then I realized that would include players, so when I tried to change it it wouldn’t work.

So you want it to ignore the player?

--I'm just adding some code that might not work, but it also sorta makes sense.

if Humanoid and UpperTorso and v ~= script.Parent and ~= Player then --I'm assuming the game is R15 

Edit: Do players in your game have a specific tool that no NPC has?

1 Like

Edit: Do players in your game have a specific tool that no NPC has?

No, they don’t. But I will try the script you sent.

1 Like

how to make so if you morph, you get renamed humanoid?

It’s an old post to be replying to, and why? When you morph that only changes the character appearance, like body type, accessories and clothing etc. The humanoid isn’t and shouldn’t be changed at all. Why would you want to make the player renamed to “Humanoid”?