How to write a variable that locates the characters head?

I wrote a line that I thought will locate a player’s head but honestly, it didn’t work, and I know that it won’t because it’s not just right.
So I need to write a ‘local’ line that locates the players/characters head in my game, and I am struggling to write it.

Here’s what I wrote:
image

Can anyone please rewrite the line for me and help?

Hey! The quickest way to do this would to have it be a local script, because you can get the local player easily from a local script.

You can read some documentation on the Player, specifically player.character here: Player | Documentation - Roblox Creator Hub

If you use LocalScript use this

game.Players.LocalPlayer.CharacterAdded:Wait()
local PlayersHead = game.Players.LocalPlayer.Character:FindFirstChild("Head")

otherwise you need to define whose head do you want to get

player.Character:FindFirstChild("Head")

I hope I helped

i use normal script in serverscript service, if dont work ill try ur method

Just so you are aware: LocalPlayer will not work in the server script (the regular script you are talking about) because that script is server side, not client.

1 Like
--server script
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
    local character = player.Character or player.CharacterAdded:Wait()
    local head = character:WaitForChild("Head")
end)
--local (client) script
local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local head = character:WaitForChild("Head")