I'd probably just go with a timer node connected with timeout(), but if you want to do it in just one script you can:
- Create a cooldown variable and set it to zero;
- When the button is pressed, disable the button;
- In process(delta) check if the button is disabled (you can use button.is_disabled()). If it is, add delta to cooldown;
- Check if cooldown is greater than or equal to your value (the button cooldown time). If it is, "un-disable" the button and set the cooldown variable to 0;
E.g.:
extends Node
const COOLDOWN_TIME = 3.0
onready var button = get_node("button_path")
var _cooldown time = 0.0
func _process(delta):
if button.is_disabled():
_cooldown_time += delta
if _cooldown_time >= COOLDOWN_TIME:
button.set_disabled(false)
_cooldown_time = 0.0
func _on_button_pressed():
button.set_disabled(true)
(By the way, what is the code tag?)