I think this should work, this is Code I found some time ago. It was originally written to rotate entire character so I changed it for only head, so I don't know how it will work
local player = game.Players.LocalPlayer
local UserInputService = game:GetService("UserInputService")
local mouse = player:GetMouse()
local character = player.Character or player.CharacterAdded:wait()
local Head= character:WaitForChild("Head")
character:WaitForChild("Humanoid").AutoRotate = false
local gyro = Instance.new("BodyGyro",Head)
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
gyro .MaxTorque = Vector3.new(math.huge,math.huge,math.huge)
gyro .P = 10000
game:GetService("RunService"):BindToRenderStep(
"Updategyro ",
Enum.RenderPriority.Character.Value,
function()
gyro .CFrame =
CFrame.Angles(
0,
math.atan2(
Head.CFrame.X-mouse.Hit.X,
Head.CFrame.Z-mouse.Hit.Z
),
0
)
end)
game:GetService("RunService"):BindToRenderStep(
"UpdateNeckC1",
Enum.RenderPriority.Character.Value,
function()
character.UpperTorso.BodyFrontAttachment.CFrame =
CFrame.new(0,-0.5,0,-1,0,0,0,0,1,0,1,-0)
*CFrame.Angles(
-math.atan2(
character.UpperTorso.BodyFrontAttachment.CFrame.Position.Y-mouse.Hit.Y,
math.sqrt((character.Head.CFrame.X-mouse.Hit.X)^2+(character.Head.CFrame.Z-mouse.Hit.Z)^2)
),
0,
0
)
end)
16 comments
It breaks.
what do you mean by that?
It does error lol
what does it say?
Workspace.FixRobloxz.LocalScript:6: bad argument #2 to '?' (Vector3 expected, got CFrame)
I changed it
It does worse. I need the head to look at the mouse.
Ok I'm changing everything I think I know how to fix this
I use motor6d bruh.
use My script
That Script? It doesnt work aaaaaaaaaaaaaaa
What do you mean by that?
then set desired angle of motor6d that CFrame.Angles( math.atan2( Head.CFrame.Y+mouse.Hit.Y, Head.CFrame.Z-mouse.Hit.Z )
I tried it before, I want it to look up and down
For just up and down, make Y and X axis 0
Nah, I already did it. :/