How to connect signals in code in Godot 4: signal.connect(callable)
By Eduardo Orellana · Updated
Connect through the signal and pass the method itself: timer.timeout.connect(_on_timeout). The Godot 3 form connect("timeout", self, "_on_timeout") fails to parse in Godot 4, with Invalid argument for "connect()" function: argument 2 should be "Callable" but is "res://…" among its errors.
AppImage, x86_64. Ubuntu 22.04, Debian 12, Fedora 39 or newer.
Intel or AMD Chromebook, with Linux turned on.
What Godot is checking
In Godot 4 a method is a value, a Callable, and signals are properties of their object. Object.connect() takes the signal name, a Callable and flags; passing the target object and a method name, as Godot 3 did, gives the wrong types for arguments 2 and 3.
timer.timeout.connect(_on_timeout) is checked when the script loads: a misspelled signal or method is a parse error instead of a silent missing connection.
Extra arguments go on the Callable: button.pressed.connect(_on_button.bind(3)) calls _on_button(3).
Reproduce it
A Godot 3 signal connection, in a Godot 4 project.
extends Node
func _on_timeout():
print("timeout")
func _ready():
var timer := Timer.new()
add_child(timer)
timer.connect("timeout", self, "_on_timeout")
What Godot 4.7.2 prints
Godot Engine v4.7.2.stable.mono.official.ed1daf0bf - https://godotengine.org
SCRIPT ERROR: Parse Error: Invalid argument for "connect()" function: argument 2 should be "Callable" but is "res://answers/how-to-connect-signals-in-code-in-godot-4/repro.gd".
at: GDScript::reload (res://answers/how-to-connect-signals-in-code-in-godot-4/repro.gd:9)
SCRIPT ERROR: Parse Error: Cannot pass a value of type "String" as "int".
at: GDScript::reload (res://answers/how-to-connect-signals-in-code-in-godot-4/repro.gd:9)
SCRIPT ERROR: Parse Error: Invalid argument for "connect()" function: argument 3 should be "int" but is "String".
at: GDScript::reload (res://answers/how-to-connect-signals-in-code-in-godot-4/repro.gd:9)
ERROR: Failed to load script "res://answers/how-to-connect-signals-in-code-in-godot-4/repro.gd" with error "Parse error".
at: load (modules/gdscript/gdscript_resource_format.cpp:46)Fix it
Connect the timer's timeout signal to the method, and a second connection with a bound argument.
More on this: How to wait in Godot 4: "yield" was removed, use await
extends Node
func _on_timeout() -> void:
print("timeout")
func _on_tick(id: int) -> void:
print("tick from ", id)
func _ready() -> void:
var timer := Timer.new()
timer.wait_time = 0.1
timer.one_shot = true
add_child(timer)
timer.timeout.connect(_on_timeout)
timer.timeout.connect(_on_tick.bind(7))
timer.start()
What the fixed script prints
Godot Engine v4.7.2.stable.mono.official.ed1daf0bf - https://godotengine.org
timeout
tick from 7Connecting with a lambda
A short handler can be written in place: timer.timeout.connect(func(): print("done")). Keep a reference to it if you need to disconnect it later.
var on_done := func(): print("done")
timer.timeout.connect(on_done)
timer.timeout.disconnect(on_done)
Verified on Godot 4.7.2
Both scripts on this page were run headless on Godot 4.7.2 (4.7.2.stable.mono.official.ed1daf0bf) on 18 October 2026, and the output above is what Godot printed, unedited.
Where the check lives in Godot's source: [gdscript_analyzer.cpp line 3475, the message](https://github.com/godotengine/godot/blob/4.7.2-stable/modules/gdscript/gdscript_analyzer.cpp#L3475), [Signal.connect in the class reference](https://github.com/godotengine/godot/blob/4.7.2-stable/doc/classes/Signal.xml).
Questions
- How do I connect a signal only once?
- Pass CONNECT_ONE_SHOT: timer.timeout.connect(_on_timeout, CONNECT_ONE_SHOT). It disconnects itself after the first emit.
- How do I connect a signal from another node?
- Through that node: $Player.died.connect(_on_player_died).
Related
- Signal is already connected to given callable
- Attempt to connect nonexistent signal '…' to callable
- Every verified Godot 4 answer
- Can Grok 4.3 write working Godot 4 code? 11 of 15 on the first try
- How to wait in Godot 4: "yield" was removed, use await
- Invalid argument for "…()" function: argument 1 should be "…" but is "…" in Godot 4
- Can LongCat 2.0 write working Godot 4 code? 11 of 15 on the first try
- Can Beam 1.0 501B A23B write working Godot 4 code? 12 of 15 on the first try
Flockbay's agent reads Godot's debugger output and fixes errors like this one in your project, on the official Godot.
Download Flockbay free