How do i add a script to a localscript that is created in a script in roblox studio

i want to write a script for a localscript that is created in a script but i dont know how
here is the code:

local starterui = game:GetService("StarterGui")
local sg = Instance.new("ScreenGui", starterui)
local fr = Instance.new("Frame",sg)
local il = Instance.new("ImageLabel", fr)
local ls = Instance.new("LocalScript", il)

--write code here for the local script

if you can help that would help me alot since i have to use this through out my whole game and it would be better if you can help me optimize the script above since it looks kinda messy and long. thanks!

1 Like

I’m pretty sure it’s impossible, unless you are using a plugin.

1 Like

Do you mean to insert code in an empty LocalScript? All script types have a .Source property, which is not writeable nor readable. You cannot insert code to blank scripts without a plugin (which is only usable in Studio).

1 Like

well can i achieve it if i wrote the script inside a modulescript or whatever? and then require the modulescript

You cant insert a code into a script from another script but you can make a script and clone it where you want so it works

1 Like

ModuleScripts’ .Source property (which is the actual code) is also locked.

1 Like