How can I instance something to a scene I am changing to?

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

I have 5 different Level scenes and in my TitleScreen scene there is a button for every level. Pressing it changes to the BaseGame scene. Now I want to instance the right level scene to the BaseGame scene. How?

Question title is very wrong.

selamba | 2020-06-27 15:58

:bust_in_silhouette: Reply From: jasonwolf493
var instancedScene = load("res://levelScene.tscn")
var level = instancedScene.instance()
  1. Create a variable to load the scene you want.
  2. Turn it into an instance
  3. Append it
:bust_in_silhouette: Reply From: selamba

instance(), as with any situation where you need to instance something