Advertisement
ZacBozer

Untitled

Jul 12th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.72 KB | None | 0 0
  1. -- Gradually regenerates the Humanoid's Health over time.
  2.  
  3. local REGEN_RATE = 100/100 -- Regenerate this fraction of MaxHealth per second.
  4. local REGEN_STEP = 0.00000000000001 -- 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