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.
-
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?
-
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.
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
-
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)