[Early Preview] Studio Script Sync

You can find information in here about it,

There’s a companion plugin and within the extension settings.

3 Likes

This is cool, personally I don’t use external editors to do my scripts, studio works for me.

Thanks for sharing the feedback!

This is an interesting one.

When we first started digging into this problem, we focused on ‘manual’ sync. The challenge with that mode of work is that every sync operation is essentially a merge operation, as the state on disk and Studio are allowed to freely diverge.

It’s definitely possible to build reasonable workflows around this, but they require extra input or rules for the user to manage. When thinking about ‘manual’ operations to move data between files and Studio, the following operations come to mind:

  • Import & Export: Manual transfers between tools using standard file formats
  • Reload: Previously imported data is ‘updated’ to reflect new state rather than new state being inserted

We need to think more about these operations for scripts - but it might be import, export and reload operations are useful for your use case. Let us know what you think!

This use case makes sense to me. One way you could unlock it today with the current feature is you could sync a ModuleScript that’s parented to a ModuleScript that is not being synced. Then with a Studio plugin you could set up a change listener that reads the synced script, mutates it, then writes to the non-synced script. This probably isn’t the exact ergonomics you’re looking for. More thought is needed on the interfaces we expose to plugins.

This sounds interesting, can you give me some examples here of where GetPropertyChangedSignal("Source") would be insufficient here?

4 Likes

Great question! Here are some tools that you may find helpful (note, these are all made by the community)

  • Selene: Linting / static analysis. This includes a ‘roblox’ library so you get linting on roblox globals too.
  • StyLua: Code formatting
  • Luau Language Server: Language server features (autocomplete, definitions etc.). Note, today LSP plugins will not work fully as they do not have the info they need to map synced scripts to their location in the DM. We plan to add this support.
5 Likes

I was under the impression that Source wasn’t guaranteed to be up to date and we shouldn’t be using it for this stuff. Especially in Team Create. Is this not the case?

This is a great question (thanks!) and one I get quite a lot. So I wanted to break down our thoughts a little more here.

The core challenge is, although the DataModel is hierarchical, it is not a file system. Some differences:

  • No naming restrictions (non-unique names, special characters).
  • Allows parent-child relationships among instances (ie files nested under files).
  • Instances contain many properties, not one blob of data
  • Instances have complex metadata (attributes, tags etc.).

That’s not to say a Roblox project can’t be represented on the file system in such a way that it can be translated to a DataModel later, but doing this requires a lot of opinions and potentially configuration. Questions like this start to pop up:

  • Should a house model be one file or each brick part a separate file?
  • How should DataModel instances be structured on disk?
  • Should assets be stored with their references?
  • How to serialize a LocalizationTable—JSON, CSV, or another format?
  • Should data prioritize space, interoperability, or other factors?
  • Should a mesh file map to a mesh asset, an instance referencing a mesh asset, or a scene of instances in the data model referencing many assets

The Rojo devs have spent a lot of time on this problem, and has built a project format that adopts enough opinions to make this work great for their use cases. However - the range of use cases for external tools is enormous. We aren’t sure every use case needs (or benefits from) a file system source of truth, nor that the rules / conventions Rojo adopts are suitable for every workflow involving external tools.

We think we can best serve the community by:

  1. Working to open up our platform so that tools like Rojo are easier for creators to build and maintain
  2. Trusting the community, and not adopting our own complex opinions on how such workflows should work (we’ll get this wrong!)
  3. Releasing first party features in this space, only when we think we have a clear value proposition and can do so in a generic way

Now… that being said. On our upcoming features list for Script Sync is Folder Sync, this will let you sync a Folder to a directory on disk. When you add a script to the Folder, it’ll automatically create the file on disk and vice-versa. The idea here being letting you sync code bases, not just individual scripts. This may address some of your use cases.

PS: Sorry for the word wall - we’re super passionate about this stuff!

9 Likes

You’ve caught me out! To the best of my knowledge ScriptEditorService.TextDocumentDidChange is the correct API for listening to open script documents, as it reflects the latest state as rendered in the script editor. ScriptEditorService also provides APIs for you to ‘submit’ transformations to the script document (even if others are writing to it) so if you want to write to a script it’s definitely encouraged you use this.

If you just want to listen to changes, subscribing to Script.Source should be fine. That being said, I don’t work on this stuff directly so if you see me delete this post later and change this that’s your signal I was wrong.

4 Likes

No plans at the moment. The challenge here is representing a Roblox project as files is non trivial. If you want a file based workflow, with your project checked into an external version control system, a tool like Rojo is the way to do this.

That being said - we know we need to do more work on the collaboration options that are built into Roblox Studio. Particularly when it comes to workflows where you want to isolate your work from each other. I can’t share any specific plans yet but this is something we’re actively thinking about.

1 Like
  1. When this is fully released, Will changes made be pushed live into the production game or will it be in studio waiting to be published?
  2. If I gave the file to someone else, would the script also sync with their edits?

Additionally, syncing updates between places for games such as a tower defenses or generally ones with a lot of maps that might be split-up into places becomes easier with this as well.

Do you have experience in doing that? I’m currently trying to sync a few modules between games and I have difficulty finding premade tools.
My first thought was to import every module into it’s own git project and automatically update the other git projects when code gets pushed to one.
…But that may just be a bit overkill

1 Like

Thanks for your questions!

  1. These changes just write to the Studio state like any change you made in Studio. It’s still up to you when you hit save / publish.
  2. The other user would need to enable script sync to sync this file. We recommend against having two users attempt to sync to the same script at the same time. It’ll work, but if you aren’t careful you’ll overwrite each other’s work.
4 Likes

Okay, thank you for the reply. Really exciting update! I totally see why this isn’t straight forward for you. If I could give my humble opinion, I think attributes, tags etc. does not have to be shown in studio, but just have to appear in autocomplete, and then you have to edit the properties in studio (unless you do it via a script).

1 Like

Do you have an (estimated) timeframe for when these 2 would be available? Right now they are the only things holding back my studio from using this new feature.

YESS, THIS WILL BE AWESOME, FINALLY :pray: THANK YOU SO MUCH ROBLOX :pray:

2 Likes

You can take advantage of Roblox Packages for this. Whenever you’d update the code within your main place, these changes will automatically be updated across all instances as long as auto updating is enabled.

1 Like

This seems like a really great future and I excited to use it even though I am more of a gui designer not a coder :rofl:

1 Like

Not 100% correct, you will still need to publish the other experiences under the universe still.

1 Like

Because they don’t have a code editor and use a file based system

1 Like

You can do

require(id)

once you publish an update to the module with that id the scripts will automatically require the new version

Import, Export and Reload operations would be sufficient for my workflow. Additionally, the icon for file sync in the explorer pane should reflect which Instances have been modified (either in Roblox or on the file system) and not synced. Please refer to my subsequent reply for an image of the Lync widget which contains these features (“Revert” = Reload, “Save” = Export.)

This achieves the result I’m aiming for. Only concern I have is how syncing raw file contents to a ModuleScript will create script errors. Perhaps the File instance could be modified to suit this purpose instead?

In the future, when more types of Instances can be synced, there must be a catch-all syncing/synced event; otherwise, it becomes tricky to listen to modifications to an instance tree of indeterminate composition, especially when some of the properties are inaccessible to plugins.

Additionally; listening to instance modifications won’t tell you if the change was made in Roblox or on the file system.


Thanks for the communication!