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

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.

Source: https://flockbay.com/godot/cannot-get-return-value-because-it-returns-void/ · Updated 2026-10-30

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

## 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
```

## 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: "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](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.

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: [Trying to return a value of type "…" from a function whose return type is "…" in Godot 4](/godot/trying-to-return-a-value-of-type-from-a-function-whose-return-type-is/), [The function signature doesn't match the parent. Parent signature is "…" in Godot 4](/godot/function-signature-doesnt-match-the-parent/), [Too few arguments for "…()" call. Expected at least N but received M in Godot 4](/godot/too-few-arguments-for-call-expected-at-least/), [Trying to call an async function without "await" in Godot 4](/godot/trying-to-call-an-async-function-without-await/), [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/)
