When I join:
After I reset:
That’s because “characteradded” also fires when the player dies.
But he’s set the default to Cool123 now. His name is Megaificent
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.
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)
char underlines when I paste that in.
That’s a good idea, but why do game.Workspace[name]
instead of player.Character
? Just curious
He removed the variable “char” from his edited script.
Oh, didn’t know that existed, my bad. You could do that.
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.
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)
Nice to know that you have solved your problem!