0

So I've recently made a start menu for a game I'm working on. And I've made a button which should spawn a window. I already set the window to hide() and I want the button when clicked to change the hide() mode to show() I've done this in my code so far:

extends Button

func _on_button_up():
    print("Button Status: clicked")
    newgame.show()
    pass # Replace with function body.

however, when I run this, it gives me the following error:

Parser Error: The identifier "newgame" isn't declared in the current scope.

P.S.: newgame is the window name that I put.

RockZombie
  • 101
  • 1
  • 9
  • The error is telling you that there isn't a variable called `newgame` (edit: nor a class called `newgame`). If you are trying to access a child node by name (being the name `"newgame"` in this case), use `get_node("newgame")` or `$newgame` (these are equivalent). If that is not what you are trying to do, please clarify. – Theraot Nov 09 '21 at 00:07
  • @Theraot I tried what you suggested, but I get the following error: `Attempt to call function 'show' in base 'null instance' on a null instance.` – RockZombie Nov 09 '21 at 00:28
  • Than that is not the name of a child node. What is `newgame` supposed to be? How did you create it? Where is it stored? – Theraot Nov 09 '21 at 00:33
  • @Theraot Thank you! Adding the window as a child node greatly helped me! – RockZombie Nov 09 '21 at 03:48

0 Answers0