How to change scene with VisualScript

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

Hello,

I’m having some trouble achieving this with visualscript:

get_tree().change_scene("res://levels/level2.tscn")

This question was answered successfully on another page, but the link used that explains the answer is now dead, unfortunately.

Here is an image of what I have so far:

If anyone could guide me in the right direction, that be awesome. Thanks!

:bust_in_silhouette: Reply From: jandrewlong

Add a CallSelf node calling get_tree() to pass the SceneTree to your CallInstance node.

:bust_in_silhouette: Reply From: jasperbrooks79

Make a ’ Get Scene Tree ’ node, drag out the obj port, on the node, you get a list of nodes that ’ work ’ right there, look for the ’ Change Scene ', or if you want to restart level, ’ Reload Current Scene ’ . .

Image link . .
Imgur

To get the path, right-click the scene you want to LOAD / change to, and click ’ copy path ', then paste that into a string variable, and put that into the ’ string ’ input of the ’ Change Scene ’ box . . .

You need the Change Scene(string) node, from the list, when you drag out the obj <3

:bust_in_silhouette: Reply From: jasperbrooks79

Or, another way to get the path, to the ’ scene ’ is, to drag the scene you want to change to, into visual script, you’ll get a ’ Preload ’ node box, a script box, that doesn’t work, but you can read the ’ path ', and put that into a string variable, also . . <3 :smiley:

Read the post below, two down, first, somehow it got moved wrong . . <3 <3

Also, the ’ Get Tree ’ visual script box doesn’t work, you need the ’ Get Scene Tree ’ node box . . <3 <3