Hello, I have a question, how to add a timer function, in which every second example would give HP a player, I can not figure out how to do this, please help me!



timer.Create( 'SomeHealthTimer', 1, 0, function()

    local ply = Entity(1) -- or any player

    ply:SetHealth( ply:Health() + 5 )

end )

[editline]20th September 2016[/editline]

It takes less time to check the wiki than it does to make a thread

Thank you.
It seems to i understood.
How to stop the timer, for example if you reach 100 HP to not go further?

if ply:Health = 100 then
stop timer
how to stop him then?

Use math clamp to clanp values from 0 to 100, otherwise you might get sometimes 103hp when you are with 98hp

but then stop the timer, if reached 100 hp? Just when consuming HP, it further continues to recover, what remains, well, so for now it is 100 HP not leaves
max 100 hp now

if ( ply:Health() >= 100 ) then
   timer.Remove( "SomeHealthTimer" )

thanks all