Advertisement
CloneTrooper1019

Roblox: Universal Fall Damage Script

Feb 23rd, 2014
9,683
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.40 KB | None | 0 0
  1. local minimumFallTime = 0.75
  2. -- ^ The minimum time the player has to fall to take damage
  3. local damagePercent = 0.5
  4. -- ^ If its 0.5, their damage is 50% of their MaxHealth * the time they fell
  5. ----------------------------------------------------------------------------
  6. local Humanoid = script.Parent.Humanoid
  7. local falling = false
  8.  
  9. function notFreeFalling()
  10.     falling = false
  11. end
  12.  
  13. function FreeFalling()
  14.     falling = true
  15. end
  16.  
  17. Humanoid.Died:connect(notFreeFalling)
  18. Humanoid.Running:connect(notFreeFalling)
  19. Humanoid.Jumping:connect(notFreeFalling)
  20. Humanoid.Climbing:connect(notFreeFalling)
  21. Humanoid.GettingUp:connect(notFreeFalling)
  22. Humanoid.FallingDown:connect(notFreeFalling)
  23. Humanoid.Seated:connect(notFreeFalling)
  24. Humanoid.PlatformStanding:connect(notFreeFalling)
  25.  
  26. Humanoid.FreeFalling:connect(FreeFalling)
  27.  
  28.  
  29. local hurtSound
  30. while not hurtSound do
  31.     for _,v in pairs(script.Parent:WaitForChild("Head"):GetChildren()) do
  32.         if v:IsA("Sound") and  v.SoundId == "rbxasset://sounds/uuhhh.wav" then
  33.             hurtSound = v
  34.             break
  35.         end
  36.     end
  37.     wait()
  38. end
  39.  
  40. while wait() do
  41.     if falling then
  42.         local start = tick()
  43.         repeat wait() until not falling
  44.         print(tick()-start)
  45.         if tick()-start >= minimumFallTime then
  46.             local h,m = Humanoid.Health,Humanoid.MaxHealth
  47.             local damage = (tick()-start)*(m*damagePercent)
  48.             hurtSound:Play()
  49.             Humanoid:TakeDamage((h<damage) and h or damage)
  50.         end
  51.     end
  52. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement