Ghost scripts! Unnecessary duplicate .gd files, ending in tscn::1

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

Hey there!

After about a year of learning, I’m getting pretty good at GDScript, but lately this thing keeps happening where I’ve created a .gd script for a scene, and I’m editing the code, and suddenly there’s two versions of it in the script file list - the second one ending in “tscn::1” - like for example I’ll have and

Typically, once it’s created, that will be the script the scene follows - so edits made to the original file won’t apply.

Any thoughts on what’s causing this, and how to prevent it from happening, or how to fix it once it DOES happen?

Appreciate y’all, as always.

:bust_in_silhouette: Reply From: jgodfrey

Sounds like maybe you’ve ticked the Built-in Script checkbox when creating a new script (from the Attach Node Script dialog)? Doing so will cause the associated script to be stored in the scene file rather than as a separate .gd script file. You can save the internal script as an external file by:

  • Select the node containing the script
  • In the inspector, hit the down-arrow beside the Script property
  • Click the Save option

Here are a few other hits on this topic that might contain useful suggestions:

Thank you for this response! But I actually don’t have the “Built-in Script” checkbox ticked? And the other links are helpful but still don’t seem to answer why it’s happening?

But it’s ok - the ghost script seems to go away when I close out of Godot and re-open it, folding any new code into the original .gd script, so as long as I don’t accidentally make code changes in that one I’ll be fine.

Appreciate you!

samjmiller | 2022-11-22 21:26