how to add a tree in a node

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

I’m creating a save system. And my tree contains all information. what I want to do is on the ready function, I’ll add it to my root node. And while doing this I came across with an error:

Invalid type in function ‘add_child_below_node’ in base ‘TabContainer’. The Object-derived class of argument 2 (SceneTree) is not a subclass of the expected argument class.

this is the sample code for understanding :

add_child_below($Belownode , Tree)

I think this is fucked up but anyone knows another way to add tree in a node?

EDIT: I debug it and change the tree to just a node and it works. But I still want that Tree

:bust_in_silhouette: Reply From: 1234ab

You can’t use the SceneTree this way as far as I know, you simply need to manipulate the root node of your tree, e.g. if you queue_free() it, the whole tree will be gone. If you reparent it, the children also get reparented (afaik). What do you mean with “But I still want that Tree”, what is something that you can’t do this way? You can use PackedScenes e.g. ( PackedScene — Godot Engine (stable) documentation in English )