The native Studio Script Sync feature fails to synchronize scripts if any ancestor of the script is an instance other than a Folder/Script.
This is relevant as I can’t access every script from my external code editor. I know a workaround would be to switch to a folder-only hierarchy, but I feel having scripts in non-folder and non-script instances is a really common thing and should be considered by ScriptSync.
For example, Script Sync works correctly when the script is located under a Folder hierarchy, but it does not sync when the script is placed under instances such as:
Frame
ScreenGui
RemoteEvent
RemoteFunction
Any other non-Folder and non-Script instance
Steps to Reproduce:
Enable Script Sync to e.g. ReplicatedStorage
Create an e.g. ScreenGui inside of ReplicatedStorage
Create a Script inside that ScreenGui
Expected Behavior:
The script should sync regardless of the types of instances in its ancestor hierarchy, as long as the script itself is a supported script object.
Actual Behavior:
The script is not synchronized and also doesn’t show the white dot in the right of the explorer.
In the image below, you can see that Script1 is synced but Script2 isn’t.
This is expected behavior. We don’t have a way to represent non-syncable instances (Folders, Scripts) on disk. As such, we have opted not to include them as part of the sync, and thus instances under them will not sync as well.
This is not possible without a way to serialize the entire data model, as without it, we cannot represent the instance on disk.
Suppose in a TeamCreate place, I sync Folder->Model->Script to disk. I close Studio. A collaborator deletes Model. I open Studio, resume sync and choose Keep Disk, with the intention of undoing the deletion, and picking up where I left off.
How will we recreate the Model? We currently don’t have a way to represent it on disk, so we cannot recreate it in Studio.
Interesting case, thanks for your response. This, however, really isn’t a common scenario and can be solved with a popup after clicking Keep Disc saying “An ancestor of the synced script was deleted and cannot be recovered. Do you want to delete your local files or keep them?”. For sure, this isn’t optimal, but removing the whole possibility of syncing scripts in anything other than a script or model is definitely the worse solution.
How would this behave if the model in the middle of the hierarchy were a script, and how if it was a folder? How does the system know that? Because of the init.luau file in it?