Advertisement
HowToRoblox

HeadRotation

Feb 15th, 2020
15,606
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.54 KB | None | 0 0
  1. local cam = workspace.CurrentCamera
  2.  
  3. local plr = game.Players.LocalPlayer
  4.  
  5. local char = plr.Character or plr.CharacterAdded:Wait()
  6. local hrp = char:WaitForChild("HumanoidRootPart")
  7.  
  8. local neck = char:FindFirstChild("Neck", true)
  9.  
  10. local y = neck.C0.Y
  11.  
  12.  
  13. game:GetService("RunService").RenderStepped:Connect(function()
  14.        
  15.     if neck then
  16.        
  17.         local camDirection = hrp.CFrame:ToObjectSpace(cam.CFrame).LookVector
  18.            
  19.         neck.C0 = CFrame.new(0, y, 0) * CFrame.Angles(0, -camDirection.X, 0) * CFrame.Angles(camDirection.Y, 0, 0)
  20.     end
  21. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement