Skip to content

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 WindowsDownload for Linux

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.

GDScript
extends Node

func reset() -> void:
	pass

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

What Godot 4.7.2 prints

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

More on this: Expected end of statement after variable declaration, found "Identifier" instead in Godot 4

GDScript
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

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

was 50, now 0

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.

More on this: The function signature doesn't match the parent. Parent signature is "…" in Godot 4

Prompt
My Godot 4 project prints this error: "Parse Error: Cannot get return value of call to "reset()" because it returns "void".". Find where it comes from and fix it. 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. 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 3455, the message.

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.

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

Download Flockbay free