SebTDZ

Untitled

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