How to deal with Alert: Error while parsing 'scene'

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

I have been working on a project for a few weeks and have gotten this error repeatedly. It will happen sometimes when I return to work on the project. Some of my scenes will become inaccessible and I am forced to remake them or try to update older saves of my project. This isn’t just the scenes; sometimes the scripts will become unusable and take on a bizarre appearance. The affected scripts and scenes are located where they should be, but I cant interact with them, even if placed in a different project. This problem has cost me a lot of time in my schoolwork and I fear I may fall behind unless I am able to deal with it.

This appears in the output when trying to load the Level scene:

scene/resources/resource_format_text.cpp:843 - res://Nodes/Maps/Level.tscn:1 - Parse Error: Expected ‘[’
Failed to load resource ‘res://Nodes/Maps/Level.tscn’.
Failed loading resource: res://Nodes/Maps/Level.tscn.
editor/editor_data.cpp:567 - Index p_idx = 1 is out of bounds (edited_scene.size() = 1).

I looked in the code and found out that the dependencies for the affected scenes have somehow been switched around., and some of the code on the end of the nodes is gone. Even when I put the correct code back where it should be, the code is still incomplete and the scenes don’t open

SGM | 2020-09-14 17:08

Furthermore, the Level scene has the same code as the Level script, minus some of the final lines. I’m assuming that somehow, the code replaced the Level.tscn code, causing some sort of weird cascade of shifting .tscn code. The Level.tscn code was on MainMenu.tscn and MainMenu.tscn was on MenuUI.tscn. MenuUI.tscn’s script is nowhere to be found.

SGM | 2020-09-14 17:12

:bust_in_silhouette: Reply From: njamster

Open res://Nodes/Maps/Level.tscn with a text editor (instead of the engine) - it is likely missing a opening bracket [ in the first line (for whatever reason).