Nametag issue incompatible with headless head characters

Hiya, scripters! I have recently come across a bug within my nametag script. The nametag will only appear for r15 Blocky characters, and will not appear for people who have headless.

There is no actual bug in the script, I just need it to be compatible for all avatar types.

local rs = game:GetService("ReplicatedStorage")
local nametag = rs.OverheadGUI
local ts = game:GetService("TweenService")

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		
		local head = char.Head
		local newtext = nametag:Clone()
		local playername = newtext.MainFrame.playername
		local playerrank = newtext.MainFrame.playerrank
		local humanoid = char.Humanoid
		local TAGS = newtext.MainFrame.TAGS
		local MOD = TAGS.MODERATOR
		local VIP = TAGS.VIP
		local DEV = TAGS.DEV
		local mp = game:GetService("MarketplaceService")
		
		humanoid.DisplayDistanceType = "None"
		
		newtext.Adornee = head
		newtext.Parent = head
		playername.Text = plr.Name
		playerrank.Text = plr:GetRoleInGroup(9266615)
		
		if plr:GetRankInGroup(9266615) >= 8 then
			MOD.Image = "rbxassetid://6586254080"
			print("mr added")
		else
			MOD:Destroy()
		end
		if mp:UserOwnsGamePassAsync(plr.UserId, 19909540) then
			VIP.Image = "rbxassetid://6586252945"
			print("vip added")
		else
			VIP:Destroy()
		end
		if plr:GetRankInGroup(9266615) >= 17 then
			DEV.Image = "rbxassetid://6588399576"
			print("dev added")
		end
		if plr:GetRankInGroup(9271020) >= 3 then
			if plr:GetRankInGroup(9271020) <= 7 then
				playerrank.Text = plr:GetRoleInGroup(9271020)
				print("mod added")
			end
		end
		if mp:UserOwnsGamePassAsync(plr.UserId, 19909540) or mp:UserOwnsGamePassAsync(plr.UserId, 19909571) then
			while true do
				local color = Color3.new(math.random(), math.random(), math.random())
				local tween = ts:Create(playername, TweenInfo.new(3), {TextColor3 = color})
				tween:Play()
				wait(3)
			end
		end
	end)
end)

All support is appreciated, thank you!

Parent the NameTag to the character’s HumanoidRootPart and position the GUI above the Head, that should work for all avatars.

1 Like

I don’t know about that. I think she should probably change the billboardgui properties.

Oh, and what property should she change?

2 Likes

Oh and btw, the headless head is actually a head if you didn’t know. So the script should work with every avatar type.

Like studsoffset or something like that

I think the issue is in the script itself - as it will appear for some people.

If you haven’t already, try adding newtext.Adornee = char.Head

no not exactly. The headless head or the character not fully loaded stuff is just an error. It will work with every avatar type. Plus you’re using the CharacterAdded event.

That’s already implemented, but thank you! ;D

Here’s an example of the nametag not appearing,

Well, you could use WaitForChild() instead of rs.NameTag. It waits until the intance is there.

It’s already waiting till the characters loaded, though.

I meant rs:WaitForChild(“NameTag”)

Oh, alright. I will give that a go.

ok it should work. Good luck on the game though

Thank you, much appreciated!!! :+1:

You should add into HumanoidRootPart instead of Head.