get_node("/Button") returns null even if there is a child button

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

I’m building a script that needs access to a button that has been added to an existing node using add_child. Using the get_node(“/Button”) is returning null for me though. Is there a way to access this child aside from get_child or get_children?

:bust_in_silhouette: Reply From: whiteshampoo

Remove the /

:bust_in_silhouette: Reply From: kidscancode

get_node("/Button") is an invalid path. If the button is a child of the node with the script, then get_node("Button") would be correct.

Note that the name must be correct. If you’re adding via add_child() and there’s already another node named “Button”, the name of the new node will be changed to prevent conflicts.