I think meta_leap has the right idea. Easier to count down than up though. Something like this:
extends Node2D
@export var stamina_wait_time := 2.
var stamina := 100.
var stamina_cooldown := 0.
##anywhere that uses stamina should do so through this function
func use_stamina(p_stamina:float) -> void:
stamina -= p_stamina
stamina_cooldown = stamina_wait_time
func regenerate_stamina() -> void:
#code to regenerate your stamina goes here
func _process(delta: float) -> void:
if stamina_cooldown > 0.:
stamina_cooldown -= delta
if stamina_cooldown <= 0.:
regenerate_stamina()
I find doing this sort of thing all in _process easier than with a Timer, because with a Timer you'd need to reset it every time you use stamina as well as stop whatever process was regenerating stamina. Ends up being more you need to manage than just a simple float. Timers have other great use cases but usually when you know you want something to happen for sure, or when it only needs to happen once or happens periodically every X seconds.