Cannot get return value of call to "…()" because it returns "void" in Godot 4

By Eduardo Orellana · Updated

The function is declared -> void, so it has no value to give back, and the script uses its result. var x = reset() with func reset() -> void stops the script loading with Cannot get return value of call to "reset()" because it returns "void". Call it on its own line, or change its return type and return a value.

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

The analyzer knows every function's declared return type. A call to a void function used where a value is needed, in an assignment, an argument or an expression, is an error at parse time, and none of the script runs.

Through an untyped variable the analyzer cannot see which function is called. var o = get_node(".") then var x = o.reset() parses, and x is null when it runs, with no error.

More on this: Trying to call an async function without "await" in Godot 4

Reproduce it

A void reset() whose result is stored.

extends Node

func reset() -> void:
	pass

func _ready() -> void:
	var result = reset()
	print(result)

What Godot 4.7.2 prints

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

SCRIPT ERROR: Parse Error: Cannot get return value of call to "reset()" because it returns "void".
   at: GDScript::reload (res://answers/cannot-get-return-value-because-it-returns-void/repro.gd:7)
ERROR: Failed to load script "res://answers/cannot-get-return-value-because-it-returns-void/repro.gd" with error "Parse error".
   at: load (modules/gdscript/gdscript_resource_format.cpp:46)

Fix it

Call it as a statement, or give it a return type that has a value.

extends Node

var score := 50

func reset() -> int:
	var old := score
	score = 0
	return old

func _ready() -> void:
	var previous := reset()
	print("was ", previous, ", now ", score)

What the fixed script prints

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

was 50, now 0

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 3455, the message](https://github.com/godotengine/godot/blob/4.7.2-stable/modules/gdscript/gdscript_analyzer.cpp#L3455).

Questions

Why did this not happen in Godot 3?
Godot 3's GDScript had no -> void check on calls. Godot 4's analyzer checks the declared return type of every call it can resolve.
Can a built-in method trigger it?
Yes. Methods such as add_child() and queue_free() return void, so var n = add_child(child) fails the same way.