How to make cooldown for button on derma? For example, every 30 seconds.
If its really something as simple as "you can press this button in 5 seconds again", all you have to do is use timer.Simple and change a simple "check" variable. So when the Button is pressed it checks if the variable is true or whatever you put it, and if it is true execute the button function, also set the variable to false and start the timer to whatever amount of seconds you want, and when that timer has run out it resets the variable to true.
Pseudocode (Just written here to give you a idea, definetly wont instantly work in gmod)
local buttoncooldown = true
OnButtonPress() function
if buttoncooldown then
--Do the stuff that the button is supposed to do
buttoncooldown = false
timer.Simple( 5, function() buttoncooldown = true end )
Sorry, you need to Log In to post a reply to this thread.