User Story:
As a developer, it is inconvenient and potentially game-breaking to change a character’s displayed name.
Elaboration:
Changing a character’s displayed name is an elaborate process. There’s the naive approach which requires creating a dummy head in a model that can be named whatever:
Sample Code:
local oldHead = character.Head
local newHead = oldHead:Clone()
local weld = Instance.new("Weld", newHead)
weld.Part0 = oldHead
weld.Part1 = newHead
local dummyModel = Instance.new("Model")
local dummyHumanoid = character.Humanoid:Clone()
character.Humanoid.Changed:connect(function(property)
dummyHumanoid[property] = character.Humanoid[property]
end)
charater.Humanoid.NameDisplayDistance = 0
dummyModel.Name = "CUSTOM NAME HERE"
dummyHumanoid.Parent = dummyModel
newHead.Parent = dummyModel
dummyModel.Parent = character
But this breaks the linking between the character and player since the Humanoid isn’t the character’s Humanoid. The character’s custom display name will always be grey and not match their TeamColor. This also breaks any scripts that don’t anticipate this kind of heirarchy (newHead getting hit by a raycast and its humanoid being damaged instead of the character’s humanoid).
There’s a more elegant approach however. When a character spawns, clone it, rename the clone, and then set the player’s character to the clone. That process is as follows:
Sample Code:
local ignore = false
player.CharacterAdded:connect(function(oldCharacter)
if ignore then return end
ignore = true
--Default spawn system will still be fighting over the character
--Spawn a new thread to wait for that to end
spawn(function()
player.Character = nil
oldCharacter.Archivable = true
local newCharacter = oldCharacter:Clone()
newCharacter.Name = "CUSTOM NAME HERE"
player.Character = newCharacter
newCharacter.Parent = workspace
--Clean up any ForceFields that are cloned to the new character
if newCharacter:FindFirstChildOfClass("ForceField") then
while oldCharacter:FindFirstChildOfClass("ForceField") do
oldCharacter.ChildRemoved:wait()
end
repeat
local forcefield = newCharacter:FindFirstChildOfClass("ForceField")
if forcefield then forcefield:Destroy() end
until not forcefield
end
ignore = false
end)
end)
This alleviates most problems, but if a script isn’t anticipating a second CharacterAdded event to be fired each time a player respawns, this could cause problems. Since it’s still a hack, it’s not suitable to include in free models which have to be able to adapt to any kind of place. Also, while it is the more elegant of the two approaches, it is still messy. Something as simple as renaming a character requires this verbose of an approach and I don’t imagine this being a commonly thought of solution as it requires an understanding of why characters can’t be renamed to begin with.
Use Cases:
- Adding roleplay class to character names e.g. “(Knight) EchoReaper”
- Roleplay names e.g. “Louis de Frankia”
- Gamer clan names e.g. “[RBX] EchoReaper”
- Level in character name e.g. “EchoReaper - Lvl 09”
-
AFK tags e.g. “
<
AFK>
EchoReaper” - etc
Desired Behavior:
There are a number of ways this could be approached. I think the most straightforward way would be to allow the character to be renamed, but that may not be the best we can do with the change. When modifying display names, it’s common to use multiple lines. Instead of just “Louis de Frankia”, I may want to use:
Louis de Frankia
(Magistrate)
Instead of allowing the character to be renamed, I believe a more elegant and empowering solution would be to convert the current name tag into a BillboardGui which is parented to the character or humanoid. With this, developers will be able to freely customize display name text, add multiple lines, or even change the appearance without needing to rebuild their own display GUI from scratch.
In addition to that however, I still believe the character should be able to be renamed. It’s a weird idiosyncrasy and keeping it will just make characters awkward to work with. I imagine this is a restriction put in place to prevent impersonation, but as the platform has grown we have eased away from that with custom chat/leaderboards – coupled with this and that it’s already possible to rename characters for malicious reasons, the restriction on character renaming is now obsolete.