Making parts of my code wait/sleep for another event to occur

Godot Version

Godot 4.0

Question

I have tried using pause and timers to make it so that a button cannot be pressed multiple times in succession, but pausing of course pauses the entire process and a timer still won’t stop the player from pressing the button. Other than creating something like a pressed variables (which was my other idea) what is the best way of making my code wait for another event to occur before the player can press the button again.

Signals and callable/lambda

button pressed, disable button, create scene tree timeout with lambda function to enable button.

Pseudo code

func _on_button_pressed():
  If button_disabled:
   Return
  Dosomthinguseful()
  disable_button()
  get_tree().create_timer(5.0s).timeout.connect(func (): enable_button())