Quick answer: Godot's script editor does not rename symbols across files, so other scripts still use the old name. Use Search > Find in Files (Ctrl+Shift+F) and Replace in Files, then reopen the project if a renamed class_name is still unknown. Renamed @export variables also lose their saved values in scenes.
A rename that takes two seconds can leave a trail of parse errors in files you have not opened. GDScript's error is accurate — the old name really is not declared anymore — so the fix is finding every place that still uses it.
Find every reference
Open Search > Find in Files in the script editor (Ctrl+Shift+F, Cmd+Shift+F on macOS), search for the old name with Whole Words enabled, and include .gd, .tscn and .tres files in the filters. Use Replace... to update them all, then review the result. Scenes can contain the name too: signal connections store method names, and AnimationPlayer call-method tracks store function names.
class_name renames
After changing class_name OldName to class_name NewName, other scripts that use OldName as a type fail, and occasionally the editor keeps resolving the old name until the global class cache is rebuilt. If errors remain after replacing all references:
- Save everything.
- Project > Reload Current Project.
- If it still fails, close the editor and delete
.godot/global_script_class_cache.cfg; it is regenerated on the next start.
Scope errors that are not renames
The same error appears when a name exists but is not visible where you use it:
func _ready():
if has_weapon:
var damage := 10
print(damage) # declared inside the if block only
Declare it before the block. Other common cases: using a member variable from a static func, which has no self; and using a node name directly instead of $NodeName.
@export and @onready variables
Renaming an @export var does not move the value saved in your scenes. The .tscn still stores old_name = 5, which Godot ignores, so the property silently reverts to its default. Re-enter the value in the Inspector, or edit the .tscn text to use the new name. For @onready var x = $Path, renaming the variable is safe, but renaming the node breaks the path at runtime with a "node not found" error, not at parse time.
Signals and connected methods
Renaming a method that is connected in the editor leaves a broken connection, shown with a warning in the Node dock. Reconnect it, or connect in code where the method name is checked by the parser:
$Button.pressed.connect(_on_start_pressed) # parse error if the method is missing
Prevent it next time
Typed code (var player: Player) gives errors at parse time instead of at runtime. External editors with the GDScript language server (VS Code with the godot-tools extension, for example) provide workspace-wide find-references, which makes renames safer.