Character.Head not being found

Hi i am trying to make a script for a overhead GUI but my script is unable to find the Character’s Head.

local groupID = 3433019

game.Players.PlayerAdded:Connect(function(Player)
	
	
	
	Player.CharacterAdded:Connect(function(Character)

		
		local guiClone = script.OverheadGui:Clone()
		
		guiClone.Parent = Character.Head
		
		local textlabel = guiClone.TextLabel
		
		local useridlabel = guiClone.TextLabel1
		
		local playerank  = Player:GetRoleInGroup(groupID)
		
		textlabel.Text = playerank
		
		useridlabel.Text = Player.Name
		
	end)
	
	
	
end)

Here’s my code. I have tried altering it but nothing seems to work.

1 Like
local groupID = 3433019

game.Players.PlayerAdded:Connect(function(Player)
	
	
	
	Player.CharacterAdded:Connect(function(Character)

		
		local guiClone = script.OverheadGui:Clone()
		
		guiClone.Parent = Character:WaitForChild("Head")
		
		local textlabel = guiClone.TextLabel
		
		local useridlabel = guiClone.TextLabel1
		
		local playerank  = Player:GetRoleInGroup(groupID)
		
		textlabel.Text = playerank
		
		useridlabel.Text = Player.Name
		
	end)
	
	
	
end)

Now it doesnt show the GUI above head at all

Define the head as a variable before attempting to parent something to it. I’ve seen weird things happen like that if you don’t.

And use FindFirstChild or WaitForChild as noted above by Tia.

just tried that and it doesnt work either

Make a script that defines the head as a variable.

local head = whatever:FindFirstChild("Head") -- since the character has been added you don't have to use wait print(head) -- and see if you are actually getting the head as the variable

1 Like

you can also

print(head.Parent)

if you’re not sure what you are capturing with your variable.

Yes i tried this and it worked thankyou!!