NameTag above character is set to default NameTag until you reset

When I join:


After I reset:
after I reset.PNG

That’s because “characteradded” also fires when the player dies.

1 Like

But he’s set the default to Cool123 now. His name is Megaificent

1 Like

Confused? What do you mean???

You said you wanted it to go away on death but characterAdded will fire when the player joins AND dies. (If I’m missing an error in your screenshot let me know.)

Again no errors, no when you join it should just have your normal username not the default one lol.

I don’t mean an error in the console, I mean if I was missing something else that went wrong in your screenshot that was relevent.

Nope, nothing else is really important than the usernames and the context behind it.

1 Like

I see what @XxMr_AltxX meant now. Try doing what he said:

Like I said, you should loop it.

local rep = game:GetService("ReplicatedStorage")
local nametag = rep.NameTag

game.Players.PlayerAdded:Connect(function(player)
	while true do
		if game.Workspace[player.Name].Humanoid.Health ~= 0 and not game.Workspace[player.Name].Head:FindFirstChild("NameTag") then
			local head = game.Workspace[player.Name].Head
			local newtext = nametag:Clone()
			local uppertext = nametag.UpperText

			newtext.Parent = head
			newtext.Adornee = head
			uppertext.Text = player.Name
		end
		wait(0.001)
	end)
end)
1 Like

char underlines when I paste that in.

That’s a good idea, but why do game.Workspace[name] instead of player.Character ? Just curious

1 Like

He removed the variable “char” from his edited script.

1 Like

Oh, didn’t know that existed, my bad. You could do that.

1 Like

Looping is definetly not the best solution here, It just takes away performance.

CharacterAdded fires when the player respawns/spawns and it should work, which is weird.
I recommend making some debugging, such as inserting some prints at CharacterAdded and see if It’s printing correctly everytime.

2 Likes

It prints everything accordingly.

local rep = game:GetService("ReplicatedStorage")
local nametag = rep.NameTag

game.Players.PlayerAdded:Connect(function(player)
	print("Added")
	player.CharacterAdded:Connect(function(char)
		print("PhysicallyAdded")
		local head = char.Head
		local newtext = nametag:Clone()
		local uppertext = nametag.UpperText
		wait(4)
		newtext.Parent = head
		newtext.Adornee = head
		uppertext.Text = player.Name
	end)
end)

Does it print even when you respawn? Where is that script located at?

I’m such an idiot. I changed nametag on the third variable in the CharacterAdded function to newtext and it worked.

local rep = game:GetService("ReplicatedStorage")
local nametag = rep.NameTag

game.Players.PlayerAdded:Connect(function(player)
	print("Added")
	player.CharacterAdded:Connect(function(char)
		print("PhysicallyAdded")
		local head = char.Head
		local newtext = nametag:Clone()
		local uppertext = newtext.UpperText

		newtext.Parent = head
		newtext.Adornee = head
		uppertext.Text = player.Name
	end)
end)

2 Likes

Nice to know that you have solved your problem!

1 Like