Signal connect invalid argument

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

I want to connect a signal in a script but I get the following error:

SCRIPT ERROR: Parse Error: Invalid argument for "connect()" function: argument 2 should be Callable but is res://characters/

This is the code:

enemy.connect("enemy_died", self, "score")

:bust_in_silhouette: Reply From: kidscancode

Godot 4.0 is pre-alpha software. It is not ready for use, and does not work in the same way as 3.x. You should not be using it if you are a beginner.

I hear what you are saying but there are many reasons to begin with the latest beta version of a software product. Regardless of whether or not the user is a beginner, there is nothing wrong with asking for clarifications about differences between versions. If anything, I believe these kinds of questions help both users of the product, and developers seeking to improve the software and documentation.

treebeard6 | 2022-11-17 03:28

:bust_in_silhouette: Reply From: ywmaa

I know my answer is two months late, but I hope it helps someone

I think it is now

$objectname.signal.connect(func() : pass)


$enemy.enemy_died.connect(func() : do something)

the example above was inline

here is an example with the other way

var onEnemyDied = func():
    pass #do something

1 Like
:bust_in_silhouette: Reply From: jgee_23_

I think this might help you.

$Button.connect("pressed", self, "_on_button_pressed")

will become


To make a signal with additional arguments, you would use the new Callable.bind():

$Button.pressed.connect(self._on_button_pressed.bind("Hello", "World"))

Signals will now have their own class, and therefore their own methods. This includes the ability to emit signals through code:


Disconnect signals:


Get all current connections:


Check if the signal is connected:


Thank you, this helped me!

treebeard6 | 2022-11-17 03:30

1 Like