Advertisement
Guest User

Roblox Head Movement R15/R6 Client Only

a guest
Dec 6th, 2019
29,805
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.90 KB | None | 0 0
  1. local Camera = workspace.CurrentCamera
  2. local Player = game.Players.LocalPlayer
  3.  
  4. local Character = Player.Character
  5. local Root = Character:WaitForChild("HumanoidRootPart")
  6. local Neck = Character:FindFirstChild("Neck", true)
  7. local YOffset = Neck.C0.Y
  8.  
  9. local CFNew, CFAng = CFrame.new, CFrame.Angles
  10. local asin = math.asin
  11.  
  12. game:GetService("RunService").RenderStepped:Connect(function()
  13.     local CameraDirection = Root.CFrame:toObjectSpace(Camera.CFrame).lookVector
  14.     if Neck then
  15.         if Character.Humanoid.RigType == Enum.HumanoidRigType.R15 then
  16.             Neck.C0 = CFNew(0, YOffset, 0) * CFAng(0, -asin(CameraDirection.x), 0) * CFAng(asin(CameraDirection.y), 0, 0)
  17.         elseif Character.Humanoid.RigType == Enum.HumanoidRigType.R6 then
  18.             Neck.C0 = CFNew(0, YOffset, 0) * CFAng(3 * math.pi/2, 0, math.pi) * CFAng(0, 0, -asin(CameraDirection.x)) * CFAng(-asin(CameraDirection.y), 0, 0)
  19.         end
  20.     end
  21. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement