Hello! Could someone help me with getting the players head to follow the mouse cursor?
I have tried getting the neck C0, I’ve tried changing the heads CFrame, but to no avail.
Even using scripts made by other people that apparently work, would make the head move and turn abnormally.
The player character uses R6 only.
Here’s a code snippet:
mouse.Move:Connect(function()
local translationvector = (character.Head.Position - mouse.hit.Position).Unit
local pitch = math.atan(translationvector.Y)
local yaw = translationvector:Cross(character.Torso.CFrame.LookVector).Y
local roll = math.atan(yaw)
local neckcframe = CFrame.Angles(pitch, roll, yaw)
character.Torso.Neck.C0 = character.Torso.Neck.C0:Lerp(character.Torso.Neck.C0 * neckcframe, 1)
end)
local PS = game:GetService("Players")
local player = PS.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local HRP = char:WaitForChild("HumanoidRootPart")
local torso = char:WaitForChild("Torso")
local neck = torso:WaitForChild("Neck")
local head = char:WaitForChild("Head")
local mouse = player:GetMouse()
local neckOffset = neck.C0.Y
mouse.Move:Connect(function()
local translationvector = (head.Position - mouse.hit.Position).Unit
local pitch = math.atan(translationvector.Y)
local yaw = translationvector:Cross(torso.CFrame.LookVector).Y
local roll = math.atan(yaw)
local neckcframe = CFrame.Angles(pitch, roll, yaw)
neck.C0 = CFrame.new(0, neckOffset, 0) * CFrame.Angles(3 * math.pi/2, 0, math.pi) * neckcframe
end)