So here's my structure.

In script 1 I have variables X In script 2 I have preloaded script 1 and thus variables X In script 3 I extend script 2

The problem is, in script 3, I cannot preload script 1 since it will throw a cyclical error. But I still need the variables from script 1 for the functions in script 3. Otherwise I get the error "Identifier isn't declared in the current scope".

How do I solve this?

Instead on preloading the script, you could use getters and setters to access the variables. You'd still need script 1 to be on a node somewhere in the tree. I usually just have dummy nodes in my project, like a Node2D/Spatial that I can put code on and call from various places. Or, if the code needs to be accessible across different levels, you can use an auto-load / Singleton.

For this case I'll just use an Autoload. I wasn't sure if there were more elegant solutions in Godot for this particular problem, but now that I know this is standard practice I'll just go with the Autoload.

It depends what you are doing. In general, developers dislike Singletons, but I find usually you will need at least one in each project (for example, switching levels while persisting variables like health, saving score or game state, etc.). You just don't want to go crazy with it and put too much stuff there, that is probably a sign of a bad design.

2 years later