# Invalid operands 'String' and 'int' in operator '+' in Godot 4

GDScript does not convert a number to text when you add it to a String. "Score: " + points with points an int stops with Invalid operands 'String' and 'int' in operator '+'. Convert it with str(points), or format it: "Score: %d" % points.

Source: https://flockbay.com/godot/invalid-operands-string-and-int-in-operator-plus/ · Updated 2026-10-30

## What Godot is checking

Every operator in GDScript is looked up for the exact pair of types on each side. String + String is defined, and so is int + int; String + int is not, so the evaluator reports the two types and the operator.

When both variables are typed, the analyzer sees the pair at parse time and the script does not load. Through untyped variables the check happens when the line runs, and the function stops there, as the run shows.

## Reproduce it

A score label built by adding an int to a String, through untyped variables.

```
extends Node

func _ready() -> void:
	var label = "Score: "
	var points = 10
	print(label + points)
	print("after")

```

## What Godot 4.7.2 prints

```
Godot Engine v4.7.2.stable.mono.official.ed1daf0bf - https://godotengine.org

SCRIPT ERROR: Invalid operands 'String' and 'int' in operator '+'.
   at: _ready (res://answers/invalid-operands-string-and-int-in-operator-plus/repro.gd:6)
   GDScript backtrace (most recent call first):
       [0] _ready (res://answers/invalid-operands-string-and-int-in-operator-plus/repro.gd:6)
```

## Fix it

Convert the number to text, or use a format string.

```
extends Node

func _ready() -> void:
	var label = "Score: "
	var points = 10
	print(label + str(points))
	print("Score: %d" % points)
	print("Score: {0}".format([points]))

```

## What the fixed script prints

```
Godot Engine v4.7.2.stable.mono.official.ed1daf0bf - https://godotengine.org

Score: 10
Score: 10
Score: 10
```

## 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: "Invalid operands 'String' and 'int' in operator '+'.". Find where it comes from and fix it. GDScript does not convert a number to text when you add it to a String. "Score: " + points with points an int stops with Invalid operands 'String' and 'int' in operator '+'. Convert it with str(points), or format it: "Score: %d" % points. Then run the game headless and check that Godot's output no longer shows it.
```

## Other pairs fail the same way

The message names whatever pair met: 'int' and 'String' when the number comes first, 'String' and 'float' for a float, 'Nil' and 'int' when a variable was never assigned. The fix is the same idea: give both sides one type before the operator.

## 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_vm.cpp line 795, the message](https://github.com/godotengine/godot/blob/4.7.2-stable/modules/gdscript/gdscript_vm.cpp#L795), [gdscript_vm.cpp lines 785 to 800, the operator evaluation](https://github.com/godotengine/godot/blob/4.7.2-stable/modules/gdscript/gdscript_vm.cpp#L785-L800).

## Questions

### Does print() need str()?

No. print("Score: ", points) takes several arguments and converts each one. Only the + operator needs both sides to be Strings.

### How do I show a float with two decimals?

"%.2f" % value formats it, so 3.14159 prints 3.14.

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 operands 'Nil' and 'int' in operator '+' in Godot 4](/godot/invalid-operands-nil-and-int/), [Invalid cast: could not convert value to '…' in Godot 4](/godot/invalid-cast-could-not-convert-value/), [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/), [Invalid argument for "…()" function: argument 1 should be "…" but is "…" in Godot 4](/godot/invalid-argument-for-function-argument-should-be/), [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/)
