How to visually refresh roblox studio script editor text without manual reopening after Script.Source changes made by a plugin?

I’m using a plugin to edit the code within a script using “Script.Source = …”, the script.source successfully changes ‘under the hood’, but I can’t see the changes until I manually close and re-open the script.

  1. Goal: How can I refresh the code within an open script, using code within the plugin that I’m using to edit the script.source, without having to close it and reopen the script in my editor manually?

  2. Issue: I can’t see the changes made to the script until I manually go click close on the script, and then re-open the script from the explorer.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

  4. Note: It seems like there’s a difference between the actual script.source code that exists, and the code that I’m seeing in the script document viewer that is open in my roblox studio script editor window.

5: Code Attempt: The code below is how I was trying to find the open script that I can visually see in the roblox studio editor, and then reopen it, but that isn’t working either.

-- 						local documents = ScriptEditorService:GetScriptDocuments()
						for _, document in documents do
							print("docuemnt is: ",document)
							-- The Command Bar can't be closed, so don't select it
							if not document:IsCommandBar() and document:GetScript():GetFullName() == script.Name then
								print("We found the proper document to close")
								document:CloseAsync()
								break
							end
						end
						wait(5)
						ScriptEditorService:OpenScriptDocumentAsync(script)

Re-enable the script and it should work

Sorry I don’t understand, is there an API endpoint you can direct me to? I’m looking to programmatically do this with code within a plugin.

So, how do I get a plugin to disable and then re-enable the script?

Oh nvm I misunderstood you, I don’t think it’s possible yet