How to add the player's username below their display name in the name tags?

What the title says. I’m trying to add something like this (with the part I want to add being the “(@USERNAME)”:
image
Obviously trying to keep the default style. Is there a way to do this?

I did see this on some other games so I’m pretty sure this can be done.

2 Likes

I’m pretty sure it a text label and the script being

Player.DisplayName

Quoting that part from the original post.

Changing humanoid’s display name should work out pretty fine in this situation:

humanoid.DisplayName = ("%s\n(@%s)"):format(player.DisplayName, player.Name)
1 Like

I’m sure there is a setting in player or humanoid that shows the DisplayName not sure though.


Currently seems to work when running this on a dummy on Studio, gonna try to do this studio thing that lets you playtest as 2 players and see if it works

It should work, just change the display name on server side for it to replicate to all clients!


Tested it, didn’t work… Is there smth I’m doing wrong?

Make sure player’s character loads in game:

plr.CharacterAdded:Connect(function(character)
   local humanoid = character:WaitForChild("Humanoid")
   humanoid.DisplayName = ("%s\n(@%s)"):format(plr.DisplayName, plr.Name)
end

Where should I place this? ServerScriptService? StarterPlayerScripts? Here’s the script, I placed it in ServerScriptService but it didn’t work

game.Players.CharacterAdded:Connect(function(character)
	local humanoid = character:WaitForChild("Humanoid")
	humanoid.DisplayName = ("%s\n(@%s)"):format(game.Players.DisplayName, game.Players.Name)
end)


Did I do something wrong?

game.Players.CharacterAdded() isn’t a valid function of game.Players.

To use CharacterAdded you’d do this:

game.Players.PlayerAdded:Connect(function(player) --Get the player who just joined
	player.CharacterAdded:Connect(function(character) --Now run CharacterAdded after getting the player
		local humanoid = character:WaitForChild("Humanoid") --Get the humanoid
		humanoid.DisplayName = ("%s\n(@%s)"):format(player.DisplayName, player.Name)
	end)
end)

I suggest you look at the Studio “Output” tab (or do /console in chat while playtesting) to see the errors in your scripts.

Here your main issue was you treated game.Players as the actual player, which isn’t correct as game.Players is where the players are stored inside the game; so for example if there’s a player called “BigFarts420” in the game, you would do game.Players.BigFarts420 to actually get that player, not game.Players.

1 Like

I always check the Studio Output and the Game console but I was too dumb to figure it out (during that time). This January, I have learned my lesson and made a working one but anyway thanks for explaining the issues and stuff! :slightly_smiling_face:

1 Like