How do i make this code for stamina stop me from sprinting and recharge when not sprinting

Godot 4.3

const STAMINA_LOSS_RATE = 25.0
	if Input.is_action_pressed("sprint"):
		%Stamina.value -= STAMINA_LOSS_RATE * delta
	const STAMINA_REGEN_RATE = 10.0
	if Input.is_action_just_released("sprint"):
		%Stamina.value += STAMINA_REGEN_RATE * delta

the issue I’m having right now is that I can get the bar to go down at a normal rate, but I won’t constantly go up because there is no .is_action_released there is only .is_action_just_released which only give stamina for the 1 frame after I stop sprinting. I just need someone to help me with that and if anyone knows how to make me stop sprinting once I reach zero stamina that would be good cause I don’t even know where to start with that.

Where is this code in? The process delta function or what?

I’d just have stamina check it’s value, then apply whatever the change rate is every frame in the process delta function.

you can use not to flip a boolean value if not Input.is_action_pressed("sprint"):, or better yet a else: to go with the if statement which acts similarly in this situation

const STAMINA_LOSS_RATE = 25.0
const STAMINA_REGEN_RATE = 10.0

if Input.is_action_pressed("sprint"):
	%Stamina.value -= STAMINA_LOSS_RATE * delta
else:
	%Stamina.value += STAMINA_REGEN_RATE * delta