When Live Scripting is enabled, UpdateSourceAsync errors and fails to set Script.Source when callback returns string containing carriage returns

To reproduce, open a fresh baseplate, ensure that Live Scripting is enabled, and run the following code in Roblox Studio’s command bar:

local myScript = Instance.new("Script") 
myScript.Parent = workspace 
game:GetService("ScriptEditorService"):UpdateSourceAsync(myScript, function() 
    return "Ok...\r\n" 
end)
assert(myScript.Source == "")

After running this code, the following error message is repeatedly printed to the output:

Kicked from Live Scripting Session: Server received illegal atomic operation

Interestingly, after opening the script in the editor, the desired content is visible for a split second before vanishing.

This is a problem for Rojo because the majority of users are on Windows and their script files likely contain CRLF line endings. The software is unusable for them as long as Live Scripting is enabled.

Expected behavior

ScriptEditorService:UpdateSourceAsync should be able to set script sources that contain CRLF line endings. If scripts only containing LF endings is a hard requirement, then it’d be acceptable for this API to replace any CRLF endings with LF endings, but I think parity with setting Script.Source is the right move here. CRLF line endings also exist in the wild in Roblox’s Catalog, so Live Scripting should probably properly support them!

12 Likes

Thanks for the report! We’ll follow up when there’s any update on the issue.

Thanks for reporting! We will update this API to replace all instances of “\r\n” with “\n” to address inconsistencies in Studio and ScriptEditor caused by the presence of “\r” in content. In the short term, could you incorporate this replacement logic into your code? Something like this:

return string.gsub(ret, “\r\n”, “\n”)

@HaxHelper, the fix has been released in the latest version of the Studio. Please let us know if you encounter any further issues. Happy coding!

1 Like