Why can't i change the name of a character?

Hello.
So I tried adding a custom character in my game through script.
But when i tried to change the character’s name to the players name it printed an error:

Also here is the script:

> local Players = game:GetService("Players");
> local char = game.ReplicatedStorage.Characters.Andrew
> 	Players.PlayerAdded:Connect(function(player)
> 	while true do
> 		player.CharacterAdded:Wait()
> 		local character = char:Clone()
> 		character.HumanoidRootPart.CFrame = player.Character.HumanoidRootPart.CFrame 
> 		player.Character:Destroy()
> 		player.Character = character
> 		character.Parent = workspace
> 		character.Name = player.Name
> 	end
> end)

Can anyone help me? What do i do?

Also have a nice day :smiley:

This is supposed to be in scripting support.

Well, try to change the name before setting the character’s name.

character.Name = player.Name
player.Character = character

If this doesn’t work then you can’t change the name because Roblox won’t allow you.

Edit: Uh… add a wait() or just don’t add a while loop, you’re going to crash your own application lol.

1 Like

Thanks! This helped. And also the while loop didn’t crash my game for some reason :smiley:

Oh yeah, you have execution timeout as the error probably.