A general solution to create a timer programmatically and tie it whatever script you want. Then set it's values and add it to the scene tree in the ready function. Once you have this you can just start and stop when you want. Some code below to help explain a little better.
var buttonTimer:Timer
func _ready():
buttonTimer = Timer.new()
#the time you want to wait to trigger in seconds
buttonTimer.set_wait_time(5)
buttonTimer.connect("timeout", self, "on_button_timeout")
add_child(buttonTimer)
func on_button_timeout() -> void:
#do whatever you want in this signal
buttonTimer.stop()
func on_button_click() -> void:
#this is the click the button function
buttonTimer.start()
Hope this helps. I forgot to mention this can be done with global script as well. You will just have to set the timer in that script and use it and trigger it from the other code. Such as listed below, you should create methods to hook into starting and stopping
func starttimer() -> void:
buttonTimer.start()
func button_trigger_method_wherever() -> void:
#in the button method where it is
GlobalNodeName.starttimer()
# when the timer times out in the global script it will trigger its timeout method where you can do what you need to inside