Skip to content

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

By Eduardo Orellana · Updated

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.

AppImage, x86_64. Ubuntu 22.04, Debian 12, Fedora 39 or newer.

Intel or AMD Chromebook, with Linux turned on.

Download for macOSDownload for WindowsDownload for Linux

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.

More on this: Out of bounds get index '…' (on base: 'Array') in Godot 4

Reproduce it

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

More on this: Invalid cast: can't convert a non-object value to an object type in Godot 4

GDScript
extends Node

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

What Godot 4.7.2 prints

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

More on this: Invalid cast: could not convert value to '…' in Godot 4

GDScript
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

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

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

More on this: Too few arguments for "…()" call. Expected at least N but received M in Godot 4

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, gdscript_vm.cpp lines 785 to 800, the operator evaluation.

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.

Flockbay's agent reads Godot's debugger output and fixes errors like this one in your project, on the official Godot.

Download Flockbay free