How do I a timer that when it runs out, it reloads the scene?

extends Node

@onready var label = $Label
@onready var timer = $Timer

func _ready():
timer.start()

func time_left_to_live():
var time_left = timer.time_left
var minute = floor(time_left / 60)
var second = int(time_left) % 60
return [minute, second]

func _process(delta):
label.text = ā€œ%02d:%02dā€ % time_left_to_live()

Use the timeout signal and the reload_current_scene function.

func _ready() -> void:
    timer.timeout.connect(reload)

func reload() -> void:
    get_tree().reload_current_scene()
1 Like