Answered by
5 years ago Edited 5 years ago
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
01 | local player = game.Players.LocalPlayer |
03 | local UserInputService = game:GetService( "UserInputService" ) |
05 | local mouse = player:GetMouse() |
06 | local character = player.Character or player.CharacterAdded:wait() |
08 | local Head = character:WaitForChild( "Head" ) |
10 | character:WaitForChild( "Humanoid" ).AutoRotate = false |
13 | local gyro = Instance.new( "BodyGyro" ,Head) |
14 | UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter |
15 | gyro .MaxTorque = Vector 3. new( math.huge , math.huge , math.huge ) |
18 | game:GetService( "RunService" ):BindToRenderStep( |
20 | Enum.RenderPriority.Character.Value, |
27 | Head.CFrame.X-mouse.Hit.X, |
28 | Head.CFrame.Z-mouse.Hit.Z |
34 | game:GetService( "RunService" ):BindToRenderStep( |
36 | Enum.RenderPriority.Character.Value, |
38 | character.UpperTorso.BodyFrontAttachment.CFrame = |
39 | CFrame.new( 0 ,- 0.5 , 0 ,- 1 , 0 , 0 , 0 , 0 , 1 , 0 , 1 ,- 0 ) |
42 | character.UpperTorso.BodyFrontAttachment.CFrame.Position.Y-mouse.Hit.Y, |
43 | math.sqrt((character.Head.CFrame.X-mouse.Hit.X)^ 2 +(character.Head.CFrame.Z-mouse.Hit.Z)^ 2 ) |