Connect signal error, "Target method not found! Specify a valid method or attach a script to target node"

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

I’m running Godot v 3.1.1. I’ve done some tutorials with v 2.x in the past, but just installed v 3.1.1 and already hitting a roadblock on something that should be pretty easy.

What I’m doing is pretty simple - just trying to connect the “pressed” signal to my Panel control object, but I get the error, “Target method not found! Specify a valid method or attach a script to target node”.

Thoughts?

Script:

extends Panel

var money = 0

func _ready():
$MoneyLabel.text = “$” + str(money)

Screenshots:

Connect Signal dialog
Connect Signal error

I noticed in the scene panel, none of the objects had a script icon attached to it. That’s strange, because the script clearly shows that it “extends Panel”. I’m not sure what happened. I restarted the project from scratch and this time the script icon appears next to the Panel object, and now the Connect Signal works without error. I have no idea what I did differently, but it’s now working.

Scene Panel script icon - working

carbon3c | 2019-09-05 17:42

Creating a script and attaching it to a scene tree are two different steps. Just naming it Panel.gd and extending Panel does not attach it to the scene tree. Two possible explanations:
(1) You just copied the script from somewhere to your resources folder but did not assign it to the Panel node.
(2) It was previously assigned to the Panel node, but you (accidentally) removed the assignment (it’s just one click, you don’t even need to confirm anything)
In both cases it’s easy to (re-)assign it to the node by selecting “add script” and just choosing the existing script.

Thomas Karcher | 2019-09-06 08:14

:bust_in_silhouette: Reply From: jamilimages

Hey there,

I have found that once you have added a new script to the specific node (parent or child node), you can go back to the signals to connect it to the node.

:bust_in_silhouette: Reply From: Meow

in Godot 3.0 you can attach signal to built in functions for example “queue_free”
Godot 3.0

but Godot 3.2 doesn’t allows you to do that
enter image description here