Invalid argument for "…()" function: argument 1 should be "…" but is "…" in Godot 4

By Eduardo Orellana · Updated

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.

Download for macOSDownload for Windows

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 12

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), [gdscript_analyzer.cpp line 2752, the Cannot pass line](https://github.com/godotengine/godot/blob/4.7.2-stable/modules/gdscript/gdscript_analyzer.cpp#L2752).

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.