Why is this giving an error, Parser Error: Error parsing expression, misplaced: func?

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

The following code is the one they use in the official Godot Doc:

extends Panel

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

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

I followed the instructions of the doc, yet it gives an error on line 6, and I can not seem to find a reason for why it is an error. (I am new to Godot and help would be really appreciated!)

You didn’t say where the error was. It’s hard to know without telling us what line.

Did you happen to copy and paste this into Godot instead of typing it in yourself? Copy-and-paste from the web will typically mess up your indentation.

kidscancode | 2019-08-29 02:14

Ah, my bad! The error is on line 6. I didn’t copy and paste, but I did follow instructions.

Probix | 2019-08-29 02:38

Nevermind, I just figured it out. I basically had to switch the order of the two functions. Stupid me.

Probix | 2019-08-29 03:33

Strange. Function order in a file doesn’t matter.

Zylann | 2019-08-29 12:58

Can you take a screenshot? I suspect there’s something there that isn’t apparent in your post above.

kidscancode | 2019-08-29 17:30