Headless Loading "problem" [Just to let you know]

! This is just a thread to inform anyone who is experiencing the same problem !

I just spent about an hour and a half figuring out that on the player’s character loading (with the headless equipped) the headless is not loaded immediately, in fact, before it is applied it is possible to obtain another head which is subsequently eliminated…

This is an example where I try to add a BillboardGui on the player’s head:

players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		local head = char:FindFirstChild("Head")
		if head then
			local newTag = Overhead:Clone()	
			local name = newTag:FindFirstChild("Name")
			local rank = newTag:FindFirstChild("Rank")
			
			if name and rank then
				name.Text = plr.Name
				rank.Text = "Rank"
				newTag.Parent = head

				-- In the next line i copyed the head that loaded before the headless in the workspace
				head:Clone().Parent = workspace
			end
		end
	end)
end)

Screenshots:

Current Headless:
image

The copy of the head that loaded before the headless:
image

The only way I have found to solve the problem is to wait for the headless to be added by using a task.wait() or char.ChildAdded

honestly… this is… dogsh…

1 Like

An easy way to fix it:

local function addTag(plr, head)
	if not head:FindFirstChild(Overhead.Name) then -- Prevent duplication
		local newTag = Overhead:Clone()	
		local name = newTag:FindFirstChild("Name")
		local rank = newTag:FindFirstChild("Rank")
		
		if name and rank then
			name.Text = plr.Name
			rank.Text = "Rank"
			newTag.Parent = head
		end
	end
end

players.PlayerAdded:Connect(function(plr)
	local childConnection = nil
	plr.CharacterAdded:Connect(function(char)
		if childConnection then
			childConnection:Disconnect()
		end
		
		childConnection = char.ChildAdded:Connect(function(part)
			if part.Name == "Head" then
				addTag(plr, part)
			end
		end)
		
		local head = char:FindFirstChild("Head")
		if head then
			addTag(plr, head)
		end
	end)
end)

Hope this helped you! have a good scripting day.

local Game = game
local Players = Game:GetService("Players")

local function OnPlayerAdded(Player)
	local function OnCharacterAdded(Character)
		local function OnChildAdded(Child)
			if (Child.Name ~= "Head") or not (Child.MeshId == "http://www.roblox.com/asset/?id=134079402" and Child.TextureId == "http://www.roblox.com/asset/?id=133940918") then return end
			--Do code here.
		end
		
		Character.ChildAdded:Connect(OnChildAdded)
		for _, Child in ipairs(Character:GetChildren()) do
			OnChildAdded(Child)
		end
	end
	
	Player.CharacterAdded:Connect(OnCharacterAdded)
end

Players.PlayerAdded:Connect(OnPlayerAdded)

Bare in mind this is a specific implementation for the ‘Headless Horseman’ package.

1 Like