Attempt to call function 'show' in base 'null instance' on a null instance.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By jjphung
:warning: Old Version Published before Godot 3 was released.

I am trying to hide/show a “Menu” Panel. How the nodes are structures is: Root “World” Node2D then the rest of the nodes are all children of “World.” The children are: “Background” Panel, “TextureButton” TextureButton, and “Menu” Panel. I have 2 scripts: 1 attached to the root node and the other script attached to the TextButton.

Under the _ready function in the root node I have get_node("Menu").hide() which successfully hides the panel. For the other script I have get_node("Menu").show() under _pressed, but it is giving the error in the title.

:bust_in_silhouette: Reply From: YeOldeDM

get_node("Menu") is going to look for a direct child of the node this script is on named “Menu”. From your description, it sounds like Menu is a sister to TextureButton, in which case you’d want your get_node() call to go to the parent, then the Menu. get_parent().get_node("Menu") or get_node("../Menu")

Check out the documentation on the get_node() method. It’s well-documented with examples, and is an important concept to understand.

Oh thank you! I don’t know why it didn’t occur to me to look at documentation first like I usually do.

jjphung | 2017-04-04 18:48