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
– ON CLIENT
The images posted show just an explanation. Is not the real result.
Any help appreciated!