Error message when following Scripting Tutorial....

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By TawLR432

Hello, community. I just started with Godot today.

I’m trying to do as the scripting tutorial says and make it so that “HELLO!” appears when I click the “press me” button while running it, but I keep getting an error message.

The final script is supposed to be this:

extends Panel

func _ready():
    get_node("Button").connect("pressed", self, "_on_Button_pressed")

func _on_Button_pressed():
    get_node("Label").text = "HELLO!"

When trying to run it, this is the error message: Attempt to call function ‘connect’ in base ‘null instance’ on a null instance.

Stack frames: 0 - res://Sayhello.gd:4

Members: Self

Under the Errors (1) tab: 0:00:01:0761 - Node not found: Button

Stack Trace (if applicable): _ready in sayhello.gd:line 4

Thank you. I’m happy to be part of this community and to create with Godot :slight_smile:

:bust_in_silhouette: Reply From: kidscancode

FYI, I edited your post to fix the code formatting. In future, please make sure to format your code properly so readers can make sense of it.

“null instance” errors almost always are due to node paths used in get_node() being incorrect. Your scene tree should look just like this one:

The script is running on Panel, so get_node("Button") is looking for a child of that node named “Button”. It seems that either you’ve changed the node arrangement or the name of the button node.