Name Tag GUI won't appear

I trying to test a NameGui I saw online and the BillboardGui just won’t show up on top of the player head. I have placed the server script in ServerScriptService and placed the GUI in ReplicatedStorage (just as the instructions and scripts told) and everything seems set until I play the game and nothing appears on top of my head. I have done everything it told me to do. I tried to test it on the published place and not in Studio and it still won’t work. Tried checking for bugs by using the “print” technique for some lines and the print message works but the gui still won’t show up. What is the problem?

Code:

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

game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
local head = char.Head
local newtext = nametag:Clone()
local uppertext = newtext.UpperText
local lowertext = newtext.LowerText
local humanoid = char.Humanoid

  humanoid.DisplayDistanceType = "None"
  
  newtext.Parent = head
  newtext.Adornee = head
  uppertext.Text = player.Name

end)
end)

Also, placing the script in StarterCharacterScripts and changing player and character to variables instead of functions works but only in StarterCharacterScripts. But I cannot keep it in StarterCharacterScripts since I have to tweak it so it can be changed by a Remote Event.

I did try to change the script so that the gui’s parent is set to the Character (Player Model) instead of just the head works shows up.

2 Likes

Try using CharacterAppearanceLoaded in player.CharacterAdded:Connect(function(char)

Should look like this:

player.CharacterAppearanceLoaded:Connect(function(char)
1 Like

I’d recommend calling WaitForChild() if for some reason this script can’t find the Character’s Head/Humanoid, if it doesn’t work can you check your Gui properties and see what they’re currently at? (Both before & during the game)

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

game.Players.PlayerAdded:Connect(function(player)
	print("Player added: "..player.Name)
	player.CharacterAdded:Connect(function(char)
		print("Character added: "..char.Name)
		
		local head = char:WaitForChild("Head")
		local newtext = nametag:Clone()
		local uppertext = newtext.UpperText
		local lowertext = newtext.LowerText
		local humanoid = char:WaitForChild("Humanoid")

		humanoid.DisplayDistanceType = "None"

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

Not sure why but you have to enter game.workspace instead of using the oncharacteradded parameter you may also use the oncharacteradded, but you have to locate the actual character in workspace, and if you want it to happen everytime oncharacteradded then you need oncharacter added, just ignore adding a parameter:

local rep = game:GetService("ReplicatedStorage")

local nametag = rep.NameTag

game.Players.PlayerAdded:Connect(function(player)
	local Character = game.Workspace:WaitForChild(player.Name)
	local newtext = nametag:Clone()
	local uppertext = newtext.UpperText
	local lowertext = newtext.LowerText
	local humanoid = Character.Humanoid

	humanoid.DisplayDistanceType = "None"

	newtext.Parent = Character.Head
	uppertext.Text = player.Name
end)

Heres a file for you to see:
Working.rbxl (41.8 KB)

For everytime player respawns:

local rep = game:GetService("ReplicatedStorage")

local nametag = rep.NameTag

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function()
	local Character = game.Workspace:WaitForChild(player.Name)
	local newtext = nametag:Clone()
	local uppertext = newtext.UpperText
	local lowertext = newtext.LowerText
	local humanoid = Character.Humanoid

	humanoid.DisplayDistanceType = "None"

	newtext.Parent = Character.Head
	uppertext.Text = player.Name
    end)
end)

Also it would be a good idea to add waitforchilds to the parts of the character.

1 Like