Plugin Development - source code

Morning, I am creating a plugin for the first time and I need to import another script, which is why I’m using Script.Source. However, I have a long script and need to use multiple lines to change the source code of the script that my plugin implements, but I’m not quite sure how.

I’ve tried using square brackets, and can’t seem to find any other solution; here is my script:

local toolbar = plugin:CreateToolbar("Music Autmation 1.0")
local toolbarButton = toolbar:CreateButton("Add Music Automation", "Click to add Music Automation to your game", "rbxassetid://3366737587")

toolbarButton.Click:Connect(function()
	local Group = Instance.new("Model", workspace)
	Group.Name = "Music Automation 1.0"
	
	local Mainframe = Instance.new("Folder", Group)
	Mainframe.Name = "Mainframe"
	
	local MainframeScript = Instance.new("Script", Mainframe)
	MainframeScript.Name = "MusicScript"
	MainframeScript.Source = "[[-- Do not edit this script

    local mainParent = script.Parent.Parent
	local songFolder = mainParent:WaitForChild("Songs")

	while true do
		for _,song in pairs(songFolder:GetChildren()) do
			if song:IsA("Sound") then
				for _,secondSong in pairs(songFolder:GetChildren()) do
					if secondSong ~= song then
						secondSong:Stop()
					end
				end

				if song.TimeLength > 100 then
					song.Volume = 2
					song:Play()
					wait(song.TimeLength + 2)
				end
			end
		end
		wait()
	end]]"
end)

I am pretty sure its:

[[
This is a string
]]

Not:

"[[
This is a string
]]"

Please correct me if I’m wrong

Source: " vs ' in strings - #6 by Cerulean7

2 Likes

Maybe it’s correct but I use this:

--[[
This is a string
]]
1 Like

Try this instead:
script.Source = [[""]]
The brackets are placed inside the string, that means it will get ignored.

correct me if im wrong

--[[
]]

That is for comments

[[
]]

That is for strings.

Although it is weird too add square brackets as multi-line strings, but it is what it is.

1 Like

When I was first looking on this I thought that you needed to comment a thing. you are right of course.