How to instance a scene of the same type as the current scene, in code

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

Normally, instancing a scene in code isn’t difficult, just use preload(). However, if I try and preload a scene of the same type as scene code I’m writing, I get a cyclic reference error on the preload() line.

Is there any way of doing this, apart from moving the code into some other scene?

:bust_in_silhouette: Reply From: LeslieS

‘duplicate’ should work.

var scene_copy = duplicate()