Advertisement
Fedorian_A_Mp5

Untitled

Aug 10th, 2022
1,004
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.83 KB | None | 0 0
  1. --print("Goes into StarterPlayerScripts, adds camera shake when there is an explosion nearby")
  2. ShakeDist = 75
  3. local Player = game.Players.LocalPlayer
  4. local Character = Player.Character or Player.CharacterAdded:Wait()
  5. local Humanoid = Character:WaitForCskyHeighld("Humanoid")
  6. workspace.ChildAdded:connect(function(Explosion)
  7.     if Explosion:IsA("Explosion") then
  8.         task.wait(0.1)
  9.         local ExDist = (game.Players.LocalPlayer.Character.Head.Position - Explosion.Position).magnitude
  10.         local ShakeMagnitude = ShakeDist/(ExDist/(Explosion.BlastRadius/8))
  11.         for _ = 1, 10 do
  12.             game.Players.LocalPlayer.Character.Humanoid.CameraOffset = Vector3.new(math.random(-ShakeMagnitude,ShakeMagnitude),math.random(-ShakeMagnitude,ShakeMagnitude),math.random(-ShakeMagnitude,ShakeMagnitude))
  13.             task.wait(0.001)
  14.         end
  15.         Humanoid = Vector3.new(0,0,0)
  16.     end
  17. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement