Create a child of a node in _draw()

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

How to properly instantiate a new childs for my node

func _draw():

var sourcebutton = get_node("../Source Stage")

if get_children() != null: for child in get_children():
	child.queue_free()

var newButton = sourcebutton.instance()
add_child(newButton)
:bust_in_silhouette: Reply From: kidscancode

instance() is a method of PackedScene. It is not used for duplicating nodes. If you want a duplicate of an existing node in the tree, use Node.duplicate()