# Identifier "…" not declared in the current scope in Godot 4

The name is not a variable, constant, function, class or autoload that the script can see from that line. print(speed) in a script with no speed declared fails to parse with Identifier "speed" not declared in the current scope. Declare it (var speed := 200.0), fix the spelling, or move the declaration out of the block that hides it.

Source: https://flockbay.com/godot/identifier-not-declared-in-the-current-scope/ · Updated 2026-10-30

## What Godot is checking

The analyzer resolves every bare name when the script loads: local variables in the enclosing blocks, then the script's members and its parent classes, then global classes, autoloads and engine singletons. A name found nowhere stops the script, and none of it runs.

Names are case-sensitive and scoped to their block. A var declared inside an if, a for or another function does not exist outside it.

When the name is a Godot 3 identifier that was renamed, the message adds the new name as a hint.

## Reproduce it

A script that prints a speed it never declares.

```
extends Node

func _ready() -> void:
	print(speed)

```

## What Godot 4.7.2 prints

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

SCRIPT ERROR: Parse Error: Identifier "speed" not declared in the current scope.
   at: GDScript::reload (res://answers/identifier-not-declared-in-the-current-scope/repro.gd:4)
ERROR: Failed to load script "res://answers/identifier-not-declared-in-the-current-scope/repro.gd" with error "Parse error".
   at: load (modules/gdscript/gdscript_resource_format.cpp:46)
```

## Fix it

Declare it as a member, where every function in the script can see it.

```
extends Node

var speed := 200.0

func _ready() -> void:
	print(speed)

```

## What the fixed script prints

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

200.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: Identifier "speed" not declared in the current scope.". Find where it comes from and fix it. The name is not a variable, constant, function, class or autoload that the script can see from that line. print(speed) in a script with no speed declared fails to parse with Identifier "speed" not declared in the current scope. Declare it (var speed := 200.0), fix the spelling, or move the declaration out of the block that hides it. Then run the game headless and check that Godot's output no longer shows it.
```

## Declared inside a block

A variable declared in an if or a loop only exists inside it. Using it after the block ends is this error. Declare it before the block and assign it inside.

```
var target: Node = null
if enemies.size() > 0:
	target = enemies[0]
print(target)

```

## An autoload or class_name that is not registered

A name like GameState only exists once the autoload is added in Project Settings, Globals, or the script carries class_name GameState. Until then every use of it is this error.

## 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 4689, the message](https://github.com/godotengine/godot/blob/4.7.2-stable/modules/gdscript/gdscript_analyzer.cpp#L4689), [gdscript_analyzer.cpp line 4687, the rename hint](https://github.com/godotengine/godot/blob/4.7.2-stable/modules/gdscript/gdscript_analyzer.cpp#L4687).

## Questions

### Why does it work in another script?

Members belong to their own script. Another node's variable is reached through that node: get_node("Player").speed, or an autoload for shared state.

### Does the error stop the whole game?

It stops that script from loading. Nodes that use it run without it, and anything calling into it fails next.

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: [Function "…()" not found in base self in Godot 4](/godot/function-not-found-in-base-self/), [Cannot find member "…" in base "…" in Godot 4](/godot/cannot-find-member-in-base/), [Preload file "…" does not exist in Godot 4](/godot/preload-file-does-not-exist/), [Cannot infer the type of "…" variable because the value is "null" in Godot 4](/godot/cannot-infer-the-type-because-the-value-is-null/), [Cannot assign a new value to a constant in Godot 4](/godot/cannot-assign-a-new-value-to-a-constant/), [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/)
