Please can someone help me

Godot Version

4.6

Question

So I am attempting to make a maze generation thing, but i keep on getting this error (or some form of it):

this is a download to the project:

Leave the main script as maze.gd and removing the maze.gd scripts from the spawner objects in the scenes corridor, crossroad, and room eliminates the error.
I can’t really run 3d projects on my system so I can’t tell exactly what you should be doing.
If you could state what you are trying do someone will be better able to help you.

The problem is that you have circular references:

  • the scenes reference the maze.gd script. Godot therefore needs to load the maze.gd script before it can finish loading the scenes.
  • the maze.gd preloads that very same scenes. Godot therefore needs to load the scenes before it can finish loading the maze.gd script

You can solve this problem by using load(...) instead of preload(...) in maze.gd:

# Array of preloaded scenes
var scenes = [
	load("res://maze_parts/corridor.tscn"),
	load("res://maze_parts/crossroad.tscn"),
	load("res://maze_parts/room.tscn")
]

Note that while this fixes your current problem you will soon face the next problem: with your current design the maze generator starts building a maze and never stops, leading to a stackoverflow exception.