Timers & Cooldowns?

This may be a very simple task to do, but I would like someone to lay it out for me because I don’t quiet understand it. What I’m wanting to do is create a cooldown on something. For example, when you press a button it will say, “High” in console. If you try to press again it will say, “You must wait 5 seconds before pressing this again”. Then of course when 5 seconds pass, you can press it again and it will say “High”.

Although the button example probably isn’t the best way to portray what I’m trying to achieve, I think it’s generally simple altogether. I just can’t find anything about it (mostly because I don’t know what this would be called).

local nextdo = CurTime() - 1 – The variable is 1 second before the current time

function CoolDownSon()
if CurTime() > nextdo then – if the current time is bigger than the variable, continue
print( “do thing” )
nextdo = CurTime() + 2 – make two seconds more than the current time the variable, so you will have to wait for 2 seconds
print( “no dont do thing” )