Advertisement
N0t_k3v1n

Camera shake

Nov 6th, 2022
10,586
2
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.58 KB | Gaming | 2 0
  1. local runService = game:GetService("RunService")
  2. local character = script.Parent
  3. local humanoid = character:WaitForChild("Humanoid")
  4.  
  5. function updCameraShake()
  6.     local currentTime = tick()
  7.     if humanoid.MoveDirection.Magnitude > 0 then
  8.         local shakeX = math.cos(currentTime * 10) * .2
  9.         local shakeY = math.abs(math.sin(currentTime * 10)) * .2
  10.         local shake = Vector3.new(shakeX, shakeY, 0)
  11.  
  12.         humanoid.CameraOffset = humanoid.CameraOffset:lerp(shake, .25)
  13.     else
  14.         humanoid.CameraOffset = humanoid.CameraOffset * .7
  15.     end
  16. end
  17.  
  18. runService.RenderStepped:Connect(updCameraShake)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement