# 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()).

Source: https://flockbay.com/godot/invalid-argument-for-function-argument-should-be/ · Updated 2026-10-30

## 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.

## 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
```

## Run 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.

```
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](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.

Download Flockbay free: Flockbay's agent reads Godot's debugger output and fixes errors like this one in your project, on the official Godot. https://flockbay.com/download/

Related: [Invalid type in static function 'from_angle' in type 'Vector2'. Cannot convert argument 1 from String to float in Godot 4](/godot/invalid-type-in-static-function-cannot-convert-argument/), [Too few arguments for "…()" call. Expected at least N but received M in Godot 4](/godot/too-few-arguments-for-call-expected-at-least/), [Invalid call to function '…' in base '…'. Expected N argument(s) in Godot 4](/godot/invalid-call-to-function-expected-arguments/), [Trying to assign value of type 'String' to a variable of type 'int' in Godot 4](/godot/trying-to-assign-value-of-type-string-to-int/), [Every verified Godot 4 answer](/godot/), [How do I see Godot’s output and errors in Flockbay?](/docs/how-do-i-see-godots-output-in-flockbay/)
