Trying to clone clone a nametag from ReplicatedStorage to a user's head

Objective: I’m looking to clone a BillboardGui from ReplicatedStorage and set the clone’s parent as a certain player’s head.

Issue: Somehow my script doesn’t seem to work with all the selected player’s name (works 1/2). I was able to conclude that the if statement runs, but there is no BillboardGui under the player’s head.

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

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		
		if(player.Name == "Player1") then
			local head = char.Head
			local nametagClone = nametag:Clone()
			
			nametagClone.Parent = head
			nametagClone.TextLabel.Text = "Owner"
		end
		
		if(player.Name == "Player2") then
			local head = char.Head
			local nametagClone = nametag:Clone()

			nametagClone.Parent = head
			nametagClone.TextLabel.Text = "Owner"
		end
		
	end)
end)

What might I be doing wrong?

1 Like

Set the adornee to Head aswell and use tables to check for special status’s instead of setting if statements for every user with a special name.

Make a table insert all the players that you want.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local nametag = ReplicatedStorage.nametag
local players = {
   ["Player1"] = {
      Rank = "Owner"
   },
  ["Player2"] = {
    Rank = "Owner"
   }
}

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		
        local head = char:WaitForChild("Head") or char:FindFirstChild("Head")
        if players[player.Name] then
            local nametagClone = nametag:Clone()
			nametagClone.Parent = head
			nametagClone.TextLabel.Text = players[player.Name].Rank
        end
	end)
end)

Thanks for the answer! What would be the adornee?

He has previously stated to set the adornee to the character’s Head.

@coolalex1835 Doesn’t seem to work!

		local head = char.Head
		local newNametag = nametag:Clone()
		
		newNametag.Parent = head
		newNametag.Adornee = head
		
		print(newNametag.Adornee.Name)
		print(newNametag.Parent)
		print(newNametag.Parent.Parent)
		
		newNametag.TextLabel.Text = "hello"
		

The output is as expected:
22:33:44.424 Head - Server - Nametags:12
22:33:44.424 Head - Server - Nametags:13
22:33:44.424 Debrikalis - Server - Nametags:14
User

Player1 was just an example! Pardon me for the confusion

Show ur new code (characterlimit)

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

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		local head = char.Head
		local newNametag = nametag:Clone()
		
		newNametag.Parent = head
		newNametag.Adornee = head
		
		print(newNametag.Adornee.Name)
		print(newNametag.Parent)
		print(newNametag.Parent.Parent)
		
		newNametag.TextLabel.Text = "hello"
		
		
	end)
end)

Change name tag’s position to head.Podition

I’m not sure if I understand. I assume you mean:

nametag.Parent = head
nametag.Adornee = head

It moves the BillboardGui “somewhere”. I tried to use the explorer but there are no returns for the BillboardGui

Name tag is being parented to the head but I assume it is just somewhere in the workspace

After CharacterAdded do this

if not player:HasAppearanceLoaded() then
	player.CharacterAppearanceLoaded:Wait()
end
1 Like

I will test that tomorrow. I appreciate very much your support!

1 Like

Then it seems like the parent is being set to nil, meaning the character’s head hasn’t been loaded yet.
Instead of char.Head, try char:WaitForChild(“Head”)