0 votes

I'm building a script that needs access to a button that has been added to an existing node using addchild. Using the getnode("/Button") is returning null for me though. Is there a way to access this child aside from getchild or getchildren?

in Engine by (15 points)

2 Answers

+2 votes
Best answer

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.

by (20,923 points)
selected by
+2 votes

Remove the /

by (1,480 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.