Important Script Source Update and New ScriptEditorService APIs

Hi Plugin Developers,

Today, we have an important update regarding the use of the source property of scripts. We are working towards adding more advanced script editor features and extending our support for third-party tools.

However, currently the script source property has multiple functionalities and this is becoming a limiting factor for future development. To solve this issue, we are introducing two APIs for reading and updating the source property of scripts. We strongly encourage you to use these instead of directly editing the source property. This will guarantee the compatibility of your plugins with future platform features.

As of today, the Source property is

  • replicated, persisted, and executed source code of the script.
  • the content of the script editor that is shown to users and edited in the UI.

We are decoupling the script editor from the Source property in order to allow more advanced editor features. To do so, we are using the following two APIs and encourage you to do so as well:

We strongly encourage you to use these APIs as we guarantee that they will always reflect the script editor’s current state. By contrast, the Source property will no longer be updated immediately while a script is being edited, instead updates will be made periodically. For a full description of Script.Source’s behavior, please see the documentation here.

As a result of these changes, the source property will not always reflect the script editor’s content and thus future studio editor features might not be compatible with plugins that directly work with the source property.

We recognize that adapting to this change requires some effort on your end. We truly believe that embracing this new direction will offer long-term advantages and a more robust scripting environment for everyone.

111 Likes

This topic was automatically opened after 10 minutes.

We really need you to specify when these changes take effect.

38 Likes

Howdy! One of the maintainers of Rojo here.

We don’t currently use this API, but we have a plan in place to use it going forward for new releases that we developed due to the excellent communication we received from Roblox. On behalf of everyone involved with the project, I want to thank the people involved for working with us to make sure we weren’t blindsided. It is greatly appreciated.

For the curious as to why we can’t immediately support it: Rojo currently writes properties synchronously and without worrying about those writes failing. We need to adequately support async writes to properties before we can use this API. Work is underway and it will be done soon.

72 Likes

There’s no indication about when the Source property is changing; or if it’s changed now. Until further indication, I do feel a bit blindsided.

11 Likes

Cool! I’ll play around with this later when I get a chance.

11 Likes

So to provide some more info since I realize it’s missing from this post: this has to do with live editing.

If you enable it right now, source edits don’t show up in open editors and the plan that was communicated to us is that they eventually won’t show at all. That may change though, since I can’t imagine they’ll be willing to break all previously existing tools even if it won’t significantly impact Rojo specifically. The time table is, regrettably, vague but my post was more meant to reflect that we had prior warning to this change and got to provide feedback as to whether it was workable for us and were given time to formulate a plan to respond.

There’s still more work to be done but I’m willing to celebrate every step of increased communication we get.

22 Likes

So, I do not really understand, Currently I use Rojo to sync my code with Visual Studio.

My Question: Is ROBLOX going to create their own Sync system? Or they will just create API’S for developers?

10 Likes

Could some more detail be given towards why new APIs are deprecating (previously) reliable functionality without advance notice to developers? This is a departure from the relationship that developers have historically had with the platform, and I would like to understand if this is going to occur down the road on other core features.

11 Likes

…I’m curious what you mean by “without advance notice” because as far as I can tell this is exactly that? Or do you mean a more general “this is happening on X date” kind of thing?

12 Likes

When?

Also, is it possible for Roblox to deprecate the Source property and behind the scenes wire reads/writes directly to these functions? Wouldn’t this ensure the best backwards compatibility with plugins?

12 Likes

I’m confused, does this mean the source property of all none ServerScriptService or ServerStorage scripts can be read from the client via potential exploits?

10 Likes

~~YOOO!! I’ve been waiting for something like this! W UPDATE Roblox!!’

No more loadstring! LETS GOOO~~

i dunno why I thought that this would run during run-time lolll still gonna have to use loadstring

13 Likes

Hi, let me add a few clarifying thoughts based on the questions so far:

  • This only affects Studio
  • We’re supporting future features and changes with this change and the timeline is a little fuzzy, but the changes will only affect future behavior. This is so the headway is reasonable.
15 Likes

My impression from the original post was that this change was being imminently released; having gone through it a few times again I can see they’re discussing a future change but I feel this could have been made clearer. My bad though :upside_down_face:

10 Likes

yes, they will. announced at rdc 2023, roblox studio will, in the future, sync code with vsc via extension

9 Likes

Bug: These new functions place the text cursor at the bottom of the script if it’s open when they are called. Setting Source directly doesn’t do this.

8 Likes

Alright, Thank you so much! I really appreciate it.

8 Likes

In new API it’s equivalent to replace the new content in editor if the script is opened, so the cursor will be moved to EOF. We suggest to update cursor position by RequestSetSelectionAsync if you need to control cursor position.

11 Likes

Thanks for the info! I’ve implemented this per your advice.

9 Likes