This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+1 vote

Hey everyone I am trying to script this thing that when a button is pressed it will hide the wings from another node. Both nodes are linked to the same main scene but I want the button when clicked to hide a specific sprite in the world. Sorta like an equip/unequip button.That's the right path by the way if that helps. Also when I get the path then do hide() it hides the entire GUI and not the item. How do I make it so it only hides the item and unhides it when the button is clicked again?

Here's my script:

extends Panel

func _ready():
    set_fixed_process(true)

func _on_MenuButton_button_down():
    get_node("Player/Shane's-Wings")
    hide()
in Engine by (21 points)

1 Answer

+1 vote

When you call hide() you are doing the same as if you were to call self.hide(), which will hide the node this script is on. All you need is to call hide() on the node you're getting on the line above.
get_node("Player/Shane's-Wings").hide()

by (1,328 points)

I did that earlier but I tried it again and i'm getting this error:

Attempt to call function 'hide' in base 'null instance' on a null instance.
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 Frequently asked questions and 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 [email protected] with your username.