0 votes

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 onTimertimeout():
get
tree().change_scene("TitleScreen.tscn")

but i want to change it to something like this:

func onTimertimeout():
IF current
scene = ("SceneOne.tscn")
gettree().changescene("TitleScreen.tscn")
ELSE
gettree().changescene("LevelSelect.tscn")

Thx.

asked May 20 in Projects by retsi3602 (21 points)

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

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.