This has been a question I wanted to know the answer for, I see plugins do it all the time. I know it is possible but all "Scripting Helpers" answers I have seen so far on various Question is a StringValue and using its value to loadstring(), though when you are using a plugin (like I want to create) you want it to be able to open the script with the code in it, not in a StringValue. Please help if you can.
Since plugins are studio-only and assumed to be trusted there are few restrictions. All you have to do is search the api.
Create and open script:
local scr = Instance.new("LocalScript",game.StarterGui) scr.Source = "test" plugin:OpenScript(scr,1)