Give money every second when alive

How would I give a player $1 every second while the player is alive? I have the money system already done, but I just couldn’t get this.

in a playerspawn hook create a timer like this[lua]timer.Create(“AliveMoney”,1,0,
function(ply)
if ply:IsAlive() then
//give money here
end
end,ply)[/lua]

uh… why did you put ,ply at the end?

Because the Function Is in the timer

Hey, thanks for the help! One thing, though.

It would be ply:Alive() instead of ply:IsAlive(). I did get it working.

Change (“AliveMoney” into (“AliveMoney”…ply:Name()

Or when it’s going to happen for all players anyway:

[lua]timer.Create( “AliveMoney”, 1, 0, function()
for _, pl in ipairs( player.GetAll() ) do
if ( pl:Alive() ) then
– Give money
end
end
end )[/lua]

Additionally, if you still have the need to use the script above, the extra ply argument isn’t necessary. This works perfectly fine:

[lua]timer.Create( “AliveMoney” … ply:Nick(), 1, 0, function()
if ( ply:Alive() ) then
– Give money
end
end )[/lua]

That’s because ply is still in the scope of that function, so it can be used.