Timers break when I load a scene

Godot Version

Godot 4.2


How do I fix a timer breaking whenever I load a scene?
I use timers on the title screen of my game for various purposes (allowing time for a confirmation sound to play, and showing an error message), and they work exactly as I expect when I directly load into the title screen scene of my game. However, as soon as I return to the title screen, the timers break, and none of the options work as I expect. I’ve tried both creating the timers in code and using nodes and the same exact thing happens. I’ll attach the code for my title screen if anybody can provide help or a better solution.

Note: The uiOption variable is leftover from me using nodes and a single timeout function.

extends Node3D
var uiOption = 0

func _ready():
	if Global.version == 3 or Global.version == 4:

func _process(delta):

func _on_play_pressed():
	uiOption = 1
	await get_tree().create_timer(0.5).timeout

func _on_quit_pressed():
	uiOption = 2
	await get_tree().create_timer(0.5).timeout

func _on_extras_pressed():
	if Global.gemsCollected == 11:
		uiOption = 3
		await get_tree().create_timer(0.5).timeout
		await get_tree().create_timer(5).timeout

func _on_options_pressed():

Please provide the exact issue you are encountering (error message, expected behavior)
Also can you please give more details into your transition system ? how do you “return to the title screen” ? what is it composed of ?

Are you putting the game on pause by any chance ?

1 Like

This did make me realize the issue, in the pause menu I set the engine time scale to zero and never set it back to 1. Thank you!

remember to flag your post as solution so the topic appears solved :innocent:

My solution is to have one Main Scene you will manage change levels in this scene, timers and all logic between levels

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.