How To Set Script Source

Name
Hi, my name is baccon!

What I’m Trying To Do
I’m trying to connect my source code to another script… I’m just a bit confused on how to do this.

ScriptThing.Click:Connect(function()
	local newScript = Instance.new("Script")
	newScript.Name = "Anti-Exploit NRBA"
	newScript.Source = ""
	newScript.Parent = game:GetService("CoreGui")
	local ModulesFolder = Instance.new("Folder", newScript)
	ModulesFolder.Name = "Modules"
	local DiscordModule = Instance.new("ModuleScript", ModulesFolder)
	DiscordModule.Name = "Discord" 
	DiscordModule.Source = ""
	local AntiExploitModule = Instance.new("ModuleScript", ModulesFolder)
	AntiExploitModule.Name = "AntiExploitTabs" 
	AntiExploitModule.Source = ""
	ChangeHistoryService:SetWaypoint("Exploit Added")
	--local GuiStarter = Instance.new("ScreenGui", game:GetService("StarterGui"))

end)
1 Like

You can only set the script’s source through plugin scripts or the command bar. If you’re setting it through those then just fill in the Source property with the source code you want the script to have. If the script is external, you’d have to make an http request to the website using HttpService and load the string from the returned JSON.

i’m using a plugin, i’m just confused on how to set it

Basically, you just do it like this:

local src = Instance.new("Script")
src.Name = "TestScript"
src.Source = "print(\"I'm a new script that was just created!\")"
src.Parent = workspace

The Source property just takes the string that you want compiled:

src.Source = "local parent = script.Parent\nprint(parent.Name)"

You could also just do:

src.Source = "local parent = script.Parent print(parent.Name)"
1 Like
-- code inside
newScript.Source = [[
print('Hello world!')
]]
2 Likes

but it will not change due to the studio pop up that asks the user to allow the plugin to edit scripts