ToxicOZ

Roblox head bobble script

Dec 8th, 2020 (edited)
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. LocalScript in StarterCharacterScripts
  2. YT-ToxicOZ
  3.  
  4. local RunService = game:GetService("RunService")
  5.  
  6. local playerModel = script.Parent
  7. local humanoid = playerModel:WaitForChild("Humanoid")
  8.  
  9. local function updateBobbleEffect()
  10. local now = tick()
  11. if humanoid.MoveDirection.Magnitude > 0 then -- Are we walking?
  12. local velocity = humanoid.RootPart.Velocity
  13. local bobble_X = math.cos(now * 9) / 5
  14. local bobble_Y = math.abs(math.sin(now * 12)) / 5
  15.  
  16. local bobble = Vector3.new(bobble_X,bobble_Y,0) * math.min(1, velocity.Magnitude / humanoid.WalkSpeed)
  17. humanoid.CameraOffset = humanoid.CameraOffset:lerp(bobble,.25)
  18. else
  19. -- Scale down the CameraOffset so that it shifts back to its regular position.
  20. humanoid.CameraOffset = humanoid.CameraOffset * 0.75
  21. end
  22. end
  23.  
  24. -- Update the effect on every single frame.
  25. RunService.RenderStepped:Connect(updateBobbleEffect)
Advertisement
Add Comment
Please, Sign In to add comment