aerobolt101

Camera/Head alignment Script

Nov 23rd, 2020
2,658
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. local camera = workspace.CurrentCamera
  2.  
  3. local character = game.Players.LocalPlayer.Character
  4. local root = character:WaitForChild("HumanoidRootPart")
  5. local neck = character:FindFirstChild("Neck", true)
  6. local yset = neck.C0.Y
  7.  
  8. local Cframe, Cfang, asin = CFrame.new, CFrame.Angles, math.asin
  9.  
  10. game:GetService("RunService").RenderStepped:Connect(function()
  11. local cameraDirection = root.CFrame:toObjectSpace(camera.CFrame).lookVector
  12.  
  13. if neck then
  14. neck.C0 = Cframe(0, yset, 0) * Cfang(0, -asin(cameraDirection.x), 0) * Cfang(asin(cameraDirection.y), 0, 0)
  15. end
  16. end)
Advertisement
Add Comment
Please, Sign In to add comment