cyclic error?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By JakeCarbine

hello I am fairly new to godot I managed to hook it up to my vscode how ever when ever I work on my game I am face with the same error in my terminal.

ERROR: Resource: 'res://Scripts/MainMenu.gd' is already being loaded. Cyclic reference?
   At: core/io/resource_loader.cpp:361

I didnt pay much attention to it till I had to implement my pause functionality and my debugger gave me this error:

E 0:00:00.602   load: Resource: 'res://Scenes/MainMenu.tscn' is already being loaded. Cyclic reference?
  <C++ Error>   Condition "!success" is true. Returned: RES()
  <C++ Source>  core/io/resource_loader.cpp:361 @ load()

any advice please

:bust_in_silhouette: Reply From: timothybrentwood

Are you preload()ing MainMenu.tscn from within MainMenu.gd?
Cyclic errors usually occur when you preload() ClassA from ClassB when ClassB already preload()s ClassA - they create a chicken and the egg problem for the script parser.

yes I did use preload() however I managed to fix the problem by using load() instead.

JakeCarbine | 2021-05-03 16:30

:bust_in_silhouette: Reply From: JakeCarbine

I fixed the problem by swapping out preload() with load() instead.