Health Regeneration System (Like in Halo, CoD 4, etc.)

Just wondering if anyone could code some health regeneration system like most games have these days. For example, after a certain amount of time after being damaged, the player’s health is regenerated over time, just like in Rainbow Six, Halo 3, CoD4, and almost every recent FPS. Shouldn’t be too hard to code. Post it here (or a link to the thread) when it’s complete.


local RegenerateAmount = 2
 local RegenerateTime = 1
 local RegenerateMax = 100
  
 local function RegenerateHealth()
     for k,v in pairs(player.GetAll()) do
         if v:Alive() then
             v:SetHealth(math.min(v:Health()+RegenerateAmount,math.max(100,RegenerateMax)))
         end
     end
     timer.Simple(RegenerateTime,RegenerateHealth)
 end
 RegenerateHealth() 

You can change the hp amount per second(s) at the top. I didn’t code this, its copied off another thread

Well, if your looking for rainbow six and Cod 4 your going to need a custom overlay for low hp. just so you know.

You need to put that regenerate health thing in a Think hook.

Do this.