How to reparent to a new node?

Godot Version

4.2

Question

I’m trying to reparent one node to another, however, the script:

func _ready():
   reparent($NewNode)

…doesn’t seem to work.

What am I doing wrong?

Hi Pauly,

reparent() is a method. You should indicate the method from the node to be rechilded

node_child.reparent(new_node_parent)

Refer to the documentation:

I encountered the same problem, parent objects may be outside of tree during initialization or even during _enter_tree. You can try reparenting them using old_parent.remove_child and new_parent.add_child methods instead, worked for me.