Timer not starting

Godot 4.2.1

My timer doesn’t seem to start even when it should be:

func update_health():
	var healthbar = $healthbar
	healthbar.value = current_health
	current_health = clamp(current_health, 0, 100)
	if current_health >= 100:
		healthbar.visible = false
	
	elif current_health <= 0:
		healthbar.visible = false
		current_health = clamp(current_health,0,100)
		player_alive = false
		
		if current_health > 0:
			player_alive = true

	else:
		healthbar.visible = true
		
func _on_regen_timeout():
	if current_health < 100:
		if in_combat == false:
			if player_alive == true:
				current_health = current_health + 10
				if current_health > 100:
					current_health = 100

func _on_in_combat_timer_timeout():
	in_combat = false
func player_revive():
	if player_alive == false:
			$AnimatedSprite2D.play("death")
			$revive.start()
			if $revive.time_left <= 0:
				print("Timer worked")


func _on_revive_timeout():
	if player_alive ==false:
		current_health = current_health + 100
		print("im alive now")
		player_alive = true
1 Like

It looks like you have 3 timers. Which one is not starting? Where do you start them? Do they autostart?

the revive timer is the one that doesn’t seem to work

Do you have a picture of the revive timer’s inspector? Maybe it is misconfigured.
Another possibility is that the signal is not properly connected.

It won’t work because you’re not waiting for the timer to end. To do this, after the start, write “await $revive.timeout”, like this.

$revive.start()
await $revive.timeout
if $revive.time_left <= 0:
				print("Timer worked")

p.s. To make the timer traceable, connect its signals through the inspector

I tried that and it didn’t change anything the timer is still not getting started and my player health isn’t going up

It’s not clear when and how are the functions player_revive and _on_revive_timeout called. Did you connect the timer signals from Inspector > Node > Signals?

player revive is in my physics process and the timer signal is connected to the player

I had the same problem, and I found out that .start() doesn’t just start the timer, it also restarts it, so if you have it running constantly it never reaches 0 it just gets restarted to its wait time.