How to do the scene change in automatic like timer??

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

I’m trying to make a load screen that in a nutshell has a 5-second cooldown, at the end of the cooldown changes the scene.

 	# Remove the current level
	var level = get_node("res://game.tscn")
	root.remove_child(level)
	root.level.call_deferred("free")

# Add the next level
	var next_level_resource = load("res://game.tscn")
	var next_level = next_level_resource.instance()
	root.add_child(next_level)

This got me on another post, but it doesn’t work, tells:

“The identifier “root” isn’t declared in the current scope.”

I don’t know if it matters that I’m making 2D game.

PS: are the first days I use Godot :wink:

:bust_in_silhouette: Reply From: klaas

Hi,
root isnt availabe in a node. You have to get the root node via:

var root = get_tree().get_root()
# or
var root = get_node("/root")

have a look here for more informations: