Parser Error Could Not parse global class

Godot Version

4.2.1.stable.mono

Question

I’m receiving a Parser Error stating that:
Parser Error: Could not parse global class “GameRoom” from “res://rooms/GameRoom.gd”

Here’s the offending lines:

func change_room(new_room: GameRoom) -> String:
	current_room = new_room
	emit_signal("room_changed", new_room)
	return new_room.get_full_description()

The GameRoom.gd file contains:

extends PanelContainer
class_name GameRoom

export (String) var room_name = "Room Name" setget set_room_name
export (String, MULTILINE) var room_description = "This is the description of the room." setget set_room_description

var exits: Dictionary = {}
var npcs: Array = []
var items: Array = []


func set_room_name(new_name: String):
	$MarginContainer/Rows/RoomName.text = new_name
	room_name = new_name


func set_room_description(new_description: String):
	$MarginContainer/Rows/RoomDescription.text = new_description
	room_description = new_description

I found that, often, this is because there’s a syntax error either in that class or in a subclass or something along that line. Make sure there’s no error somewhere. A dependent file or something. It’s not always on that class specifically.

If you can’t find anything, reloading the project might help. Or close and reopen Godot if you prefer that way.

Hopefully it’s that simple.

In v4 it should be @export instead of just export and this may be causing the trigger

1 Like

Yes as GlitchedCode says your export lines are the wrong syntax.
I am guessing you are following a tutorial? That code is GODOT 3.x and needs to be converted to 4.x