Is posible to get the players head using a script? [SOLVED]

Because I have a rank tag or something and I want to edit the code in other script.

1 Like

It is possible. Players’ characters are loaded onto Workspace. I don’t know how your code is set up, but the simplest way to do so in a ServerScript is:

local Head = game:GetService("Players").Your_Player_Name.Character:FindFirstChild("Head")

You can find the head on the player’s character so it would be:

player.Character.Head

assuming the variable “player” is the Player you want to add the rank tag.

player.Character.Head.OverHeadGUI.Frame
like that?

If you have parented the GUI on the head already, then yes.

But I want it to be automatic that you dont need to type your username

Do I need to use :FindFirstChild(“Head”)

Then parent the GUI after their character is loaded, using a game.Players.PlayerAdded event and then a player.CharacterLoaded event.

game:GetService('Players').PlayerAdded:Connect(function(Player)
 Player.CharacterAdded:Connect(function(Character)
  local Head = Character:WaitForChild('Head');

  -- Code...?
 end)
end)

So it will be Character.Head right

Thanks maybe it will be fixed I’m trying it in roblox studio

Since you want a tag above others’ heads, you can loop through all the Players in the service with :GetPlayers().

for _, Player in pairs(Players:GetPlayers()) do
	local Head = Player.Character:FindFirstChild("Head")
	
	if Head then
		-- Test if head has tag or something?
		-- then add a tag if it does not.
	end
end

If someone dies the Character will reload without the GUI so its better to do it with events like I said before.

Is this better than this? Is posible to get the players head using a script? - #9 by Itz_Louu

I believe it’d be better to use PlayerAdded in your scenario.

1 Like

@Itz_Louu’s code should work better for automatically adding tags unless you need to do something else with the tags or the heads after making them.

IDK if this is right

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        local Head = character:WaitForChild("Head")
        Head.OverHeadGui.Frame.IconHolder.Computer.Visible = true
    end)
end)

Assuming the “OverheadGui” is already parented, it should work.
If not, you can Clone the Gui & Parent it to the Character’s Head.

1 Like

But I already cloned it and I don’t want the gui get double

So it should work, no?
Check if the Gui is parented to the Character’s Head.