Why won't my nametag script work? Please help!

Am currently working on a game and have a billboard GUI that displays their HP, leaderboard stats and name above the player’s head but there’s an issue, the name label doesn’t display their username when the player spawns it just says “namelabel”.

I already have a separate script that parents the billboardGui to the player but the namelabel won’t work on spawn, I would have to reset my character for it to work… How can I fix this?

Where the namelabel is located:
Capture2

Inside the script:
43

Final results:
Capture

If I were to reset, then my name would appear. I want it to appear when I enter the game though.

Please help! :cry:

1 Like

Im thinking you would have to do something like
local players = game:GetService(“Players”)
local nametag = game.ServerStorage.BillboardGui

players.PlayerAdded:Connect(function(player)
(and what you wrote here)
end)

Hope that helps!

1 Like

I agree with @TerminatebruhDOGE, When a player joins you should update the GUI.

Hey!
I tried your script and it didn’t work. :cry:

I may have written it wrong?

Capture

Hm, I may have written it wrong then because it didn’t work for me. :slightly_frowning_face:

Hmmm, maybe it doesnt work because there are two variables known as “nametag”, maybe remove the local code thats inside the function?

You would do a big favour if you used ```` instead of screenshots.
like this

-- Hi
local Message = "hi"
1 Like

@TerminatebruhDOGE just noticed I wrote the “local nametag = game.ServerStorage.BillboardGui” twice, unfortunately I still got the same results.

local nametag = game.ServerStorage.BillboardGui

players.PlayerAdded:Connect(function(player)

	nametag.NameLabel.Text = script.Parent.Parent.Parent.Parent.Name
end)

The script I have in the namelabel.

1 Like

Uh I think I found the problem.

I was wondering how I could do that, thanks.

1 Like

I’d appreciate the solution to the problem!

Wait, whats the problem I’m interested

local nametag = game.ServerStorage.BillboardGui

players.PlayerAdded:Connect(function(player)
      player.CharacterAdded:Connect(function(char)
       local TagToGive = nametag:Clone()
	nametag.NameLabel.Text = player.Name
nametag.Parent = char:FindFirstChild("Head")
end)
end)
2 Likes

Instead of script.Parent.Parent.Parent.Parent.Name do player.Name. For the sake of efficiency.

2 Likes

One second, Sorry for the delay, What I was going to say was the script needs to be in server script service you need a remote event in replicated storage, when a player joins you will fire the remote event and pick it up on the client updating the gui, If you give me a min, ill write an example

No, thats not needed. This shouldn’t be done on the client. By using the character added event you are already making the changes needed.

Oh, Sorry about that then, my bad

Use the .CharacterAdded event like @LoafingHour said

1 Like

It’s all good (more characters)

1 Like