Advertisement
WeDoScripts

Fast Regain and more Health

Feb 16th, 2019
1,577
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. -- Gradually regenerates the Humanoid's Health over time.
  2.  
  3. local REGEN_RATE = 1/10000 -- Regenerate this fraction of MaxHealth per second.
  4. local REGEN_STEP = 0.1 -- Wait this long between each regeneration step.
  5.  
  6. --------------------------------------------------------------------------------
  7.  
  8. local Character = script.Parent
  9. local Humanoid = Character:WaitForChild'Humanoid'
  10.  
  11. --------------------------------------------------------------------------------
  12.  
  13. while true do
  14. while Humanoid.Health < Humanoid.MaxHealth do
  15. local dt = wait(REGEN_STEP)
  16. local dh = dt*REGEN_RATE*Humanoid.MaxHealth
  17. Humanoid.Health = math.min(Humanoid.Health + dh, Humanoid.MaxHealth)
  18. end
  19. Humanoid.HealthChanged:Wait()
  20. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement