So I took a player head movement script and tried to implement it into my NPC like so:
local neck = torso.Neck
local direction = HRP.CFrame:toObjectSpace(head.CFrame).lookVector
neck.C0 = CFrame.new(0, neck.C0.Y, 0) * CFrame.Angles(3 * math.pi/2, 0, math.pi) * CFrame.Angles(0, 0, -math.asin(direction.x)) * CFrame.Angles(-math.asin(direction.y), 0, 0)
However it doesn’t work. The head is just facing the left without moving at all. The player movement system works completely fine though, which is what really confuses me. How can I achieve accurate head movement?
I already declared the variables I just didn’t show them in the example. There are no output errors for the code so the problem just has to do with the positioning and offset of the neck.