Help making an organization plugin

  1. What do you want to achieve?
    I’m trying to create a plugin that creates a folder in replicated storage and automatically moves all remote events into the folder.

  2. What is the issue?
    Idk what the issue is, there are no console errors or obvious mistakes to me.

local uselessVariable
-- Create a new toolbar section titled "Custom Script Tools"
local toolbar = plugin:CreateToolbar("Rep Storage Auto Org")

-- Add a toolbar button named "Create Empty Script"
local newFolderButton = toolbar:CreateButton("Organize", "Organize", "rbxassetid://2112677849")

local function onNewScriptButtonClicked()
	local newFolder1 = Instance.new("Folder")
	newFolder1.Name = "Remote Events"
	newFolder1.Parent = game:GetService("ReplicatedStorage")
	while uselessVariable == true do
		local tables = {}
		local othertables = {}
		for _, item in pairs(game:GetService("ReplicatedStorage")) do
			if item:IsA("RemoteEvent") then
				table.Insert(othertables, item)
			end
		end
		if tables[game:GetService("ReplicatedStorage"):FindFirstChildWhichIsA("RemoteEvent")] then
			if tables == othertables then
				break
			end
		else
			table.Insert(tables, game:GetService("ReplicatedStorage"):FindFirstChildWhichIsA("RemoteEvent"))
		end
	end
	game:GetService("ReplicatedStorage"):FindFirstChildWhichIsA("RemoteEvent")
	local newFolder2 = Instance.new("Folder")
	newFolder2.Name = "StoredItems"
	newFolder2.Parent = game:GetService("ReplicatedStorage")
end
newFolderButton.Click:Connect(onNewScriptButtonClicked)

Did you define uselessVariable? You should add some print to debug and see what isn’t working.

Edit: Also you did not get the children of ReplicatedStorage

Wait, I just realized its not working because I forgot to implement code that would move the remote events into the folder. :rofl: :joy:

Now when I run the code I get the error “attempt to call a nil value on line 17”

if v:IsA("RemoteEvent") then
				table.Insert(othertables, v)
				v.Parent = newFolder1
				print(tables)
				print(othertables)
			end

Which line is line 17? Make sure v and newFolder1 exists and is defined.

Line 17 is the first line on the quoted code, so

if v:IsA("RemoteEvent") then

That means v doesn’t exist or is not defined. Make sure in your code v is a instance.

How would I make v an instance?

Are you using a for i,v in pairs() loop? To avoid this error you can just add this to the if statement.

if v and v:IsA("RemoteEvent") then
				table.Insert(othertables, v)
				v.Parent = newFolder1
				print(tables)
				print(othertables)
			end

Ok, I figured it out. The problem was the script was trying to insert the object into a table but that was calling a nil value. Thanks for the help! :+1: