How do i change scene based upon the current scene

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

Hi, im really new to gdscript and I’m trying to make a game for a school project and i cant figure out how to change the scene.tscn based upon what scene i am already in.

Currently I’ve just been using a timer when my player dies that changes back to the title screen.

func _on_Timer_timeout():
get_tree().change_scene(“TitleScreen.tscn”)

but i want to change it to something like this:

func _on_Timer_timeout():
IF current_scene = (“SceneOne.tscn”)
get_tree().change_scene(“TitleScreen.tscn”)
ELSE
get_tree().change_scene(“LevelSelect.tscn”)

Thx.

We can get the current scene path using get_tree().current_scene.filename
Now extracted to filename from the path.

_nabajit | 2020-05-20 07:39