What am I doing wrong? [scripting]

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

I am trying to make a button hide the wings when clicked. the button works when I don’t add .hide() to the end but I want to hide the wings. I am getting this error:

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

extends Panel

func _ready():

func _on_MenuButton_button_down():

Can you post a capture of the relevant part of your node tree, please?

rredesigns | 2017-05-09 04:52

:bust_in_silhouette: Reply From: wombatTurkey

get_node("Player/Shane's-Wings") is the wrong path, as it’s returning null. Use the correct path to the node there and it should work

Still won’t work I copied the path straight from the node by ctrl + c and pasted it in.

ShaneGrey413 | 2017-05-08 04:37

The path you’re giving in your get_node() call is currently looking for a child of the button (this script’s node) named “Player”. My guess is this is probably not the case.

Node — Godot Engine (stable) documentation in English

The get_node() documentation covers how these paths work pretty well. From that, you should be able to figure out the correct path according to your own game’s scenetreee.

YeOldeDM | 2017-05-08 05:17