How to make player's head facing the same direction as camera in first person

I’m making a first person system and don’t know how can I make a player’s head facing the same direction as the player is facing with the camera in first person. I mean that the player’s head must to have the same orientation as the camera.
I’ve tried so much things and searching on web but didn’t find anything like my problem. Also this is what I tried so far (Found on web) but I need a part as a TARGET to do this… This script ( Not made by me ) makes the player’s head facing a part position but not what the CAMERA is facing.

local target = workspace.Part  -- Here is what I mean
local Head = script.Parent.Parent:WaitForChild('Head')
local neckJoint = Head.Nec
local upperTorso = neckJoint.Part0 

local function worldCFrameToC0ObjectSpace(motor6DJoint,worldCFrame) 	
	local part1CF = motor6DJoint.Part1.CFrame
	local c1Store = motor6DJoint.C1 
	local c0Store = motor6DJoint.C0 	
	local relativeToPart1 =c0Store*c1Store:Inverse()*part1CF:Inverse()*worldCFrame*c1Store 	relativeToPart1 -= relativeToPart1.Position 	 	
	local goalC0CFrame = relativeToPart1+c0Store.Position 
	return goalC0CFrame 
end   

while true do 	
	task.wait() 	
	local goalCF = CFrame.lookAt(Head.Position, target.Position, upperTorso.CFrame.UpVector) 	
	neckJoint.C0 = worldCFrameToC0ObjectSpace(neckJoint,goalCF)
end

– ON SERVER
RobloxScreenShot20230726_143608762

– ON CLIENT
RobloxScreenShot20230726_143553090

The images posted show just an explanation. Is not the real result.

Any help appreciated! :slight_smile:

1 Like

I haven’t tried the code but you should maybe be using renderstepped or runservice, etc; instead of a while true loop.

I used it because i want it to be seen to other players. I mean to the whole server. So I did it in server script. Also i posted some images on what I want to tell

I believe a while true loop in the server is even worse. Regardless, is the code giving any errors in the output?

no. But I want the player head to have the same orientation as the player’s camera orientation like in the images. That script was just an example