Advertisement
Navarone19_CH

Fall Damage

Mar 26th, 2020
5,168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. local foot = nil
  2. local ts = nil
  3.  
  4. repeat
  5. wait()
  6. foot = script.Parent:FindFirstChild("Right Leg") or script.Parent:FindFirstChild("RightFoot")
  7. ts = script.Parent:FindFirstChild("Torso") or script.Parent:FindFirstChild("UpperTorso")
  8. until foot ~= nil and ts ~= nil
  9.  
  10. function toPos(num)
  11. local v = tostring(num)
  12. if string.sub(v,1,1) == "-" then
  13. return tonumber(string.sub(v,2,#v))
  14. else
  15. return num
  16. end
  17. end
  18.  
  19. local hum = ts.Parent:FindFirstChild("Humanoid")
  20. local maxFall = 0
  21. local lastFall = false
  22.  
  23. hum.FreeFalling:connect(function(p)
  24. lastFall = p
  25. if p == true then
  26. while lastFall == true do
  27. wait(0.1)
  28. maxFall = toPos(ts.Velocity.Y)
  29. end
  30. else
  31. if maxFall >= math.random(61,78) then
  32. hum.Health = hum.Health - toPos(ts.Velocity.Y)*math.random(86,98)/math.random(98,126)
  33. end
  34. maxFall = 0
  35. end
  36. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement