How do I prevent a specific node from restarting?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By si444n

So I have a 2mins countdown for my game and I want it to not restart when the player retries the game. I use get_tree().change_scene() for the restart button and whenever I click the restart button the whole scene will restart. I want the timer to be excluded from the restart. TIA!!

:bust_in_silhouette: Reply From: zhyrin

Well, you need to put your timer outside of the part of the tree that gets changed. You could try using an autoload singleton to store your timer, you could extend the SceneTree and add a SceneTreeTimer member.
Or you could change only a part of the scene tree instead of using SceneTree.change_scene().