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 Windows

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

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.