Invalid argument for "…()" function: argument 1 should be "…" but is "…" in Godot 4
The function declares a parameter type and the call passes a different one. heal("5") on func heal(amount: int) fails to parse with Cannot pass a value of type "String" as "int" and Invalid argument for "heal()" function: argument 1 should be "int" but is "String". Pass the declared type: heal(5), or convert, heal(text.to_int()).
AppImage, x86_64. Ubuntu 22.04, Debian 12, Fedora 39 or newer.
Intel or AMD Chromebook, with Linux turned on.
What Godot is checking
When the analyzer knows the function and the argument's type, it checks each argument against its parameter. A String is not an int and does not convert to one implicitly, so the script stops; Godot prints both messages for the one argument.
An int passed to a float parameter is accepted: numbers convert to each other. Text never converts to a number implicitly.
More on this: Invalid call to function '…' in base '…'. Expected N argument(s) in Godot 4
Reproduce it
A heal(amount: int) function called with text.
extends Node
func heal(amount: int) -> void:
print("healed ", amount)
func _ready() -> void:
heal("5")
What Godot 4.7.2 prints
Godot Engine v4.7.2.stable.mono.official.ed1daf0bf - https://godotengine.org
SCRIPT ERROR: Parse Error: Cannot pass a value of type "String" as "int".
at: GDScript::reload (res://answers/invalid-argument-for-function-argument-should-be/repro.gd:7)
SCRIPT ERROR: Parse Error: Invalid argument for "heal()" function: argument 1 should be "int" but is "String".
at: GDScript::reload (res://answers/invalid-argument-for-function-argument-should-be/repro.gd:7)
ERROR: Failed to load script "res://answers/invalid-argument-for-function-argument-should-be/repro.gd" with error "Parse error".
at: load (modules/gdscript/gdscript_resource_format.cpp:46)Fix it
Pass an int, converting text first when that is what you have.
extends Node
func heal(amount: int) -> void:
print("healed ", amount)
func _ready() -> void:
heal(5)
var typed := "12"
heal(typed.to_int())
What the fixed script prints
Godot Engine v4.7.2.stable.mono.official.ed1daf0bf - https://godotengine.org
healed 5
healed 12Run this fix with your agent
Flockbay is the Godot editor with an AI agent built in. Paste this into Flockbay's chat, or into Claude Code or Codex connected to Flockbay over MCP: the agent finds the cause in your project, applies the fix, runs the game headless and reads Godot's output to check it.
More on this: The function signature doesn't match the parent. Parent signature is "…" in Godot 4
My Godot 4 project prints this error: "Parse Error: Invalid argument for "heal()" function: argument 1 should be "int" but is "String".". Find where it comes from and fix it. The function declares a parameter type and the call passes a different one. heal("5") on func heal(amount: int) fails to parse with Cannot pass a value of type "String" as "int" and Invalid argument for "heal()" function: argument 1 should be "int" but is "String". Pass the declared type: heal(5), or convert, heal(text.to_int()). Then run the game headless and check that Godot's output no longer shows it.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, gdscript_analyzer.cpp line 2752, the Cannot pass line.
Questions
- Why are there two errors for one argument?
- The analyzer reports the conversion it could not make (Cannot pass a value of type) and the call it rejected (Invalid argument for). Both point at the same argument.
- What if the value comes from an untyped variable?
- Then the check happens at run time, and the call fails when the line runs instead of when the script loads.
Flockbay's agent reads Godot's debugger output and fixes errors like this one in your project, on the official Godot.
Download Flockbay free