(plugin help) How do I get a table of only scripts that the user created?

  1. What do you want to achieve?
    I’m making a plugin with useful tools for scripts. There’s a selector menu to select scripts in the game.

  2. What is the issue?
    I’m not sure how to get a table of scripts that only has scripts created by the user. When I get all the scripts, I get scripts that are even hidden:
    image image image
    None of the following scripts are visible anywhere in the explorer and ctrl+shift+f doesn’t show them either. It’s really annoying to have over 1.5 thousand scripts in a tiny scrolling frame when only about 10 of them are actually made by the user.

  3. What solutions have you tried so far?
    I wrapped the script-finder function in a pcall to make sure I don’t get any core scripts to error my code but I honestly don’t have any other solutions.

This is the segment of my plugin script that checks if the given instance is a valid script:

local function checkIfScript(inst)
	local isgood = false
	local s,e = pcall(function()
		if inst:IsA("Script") or inst:IsA("LocalScript") or inst:IsA("ModuleScript") then
			if inst.Parent.Name ~= "KasCode Script Tools"
				and inst.Parent.Name ~= "KCSTSelector"
				and not scrollingframe:FindFirstChild(inst.Name) then
				isgood = true
			end
		end
	end)
	return isgood
end

Welp, I found a solution.

Turns out I should’ve checked for thing:IsA("BaseScript") which doesn’t include default scipts. I only get user-made scripts now!

Edit:

1 Like

Nevermind, still not entirely fixed!

BaseScripts are only scripts that run automatically like LocalScripts and ServerScripts. Sadly this does not include ModuleScripts!

Does anybody have a way of checking if a module script is made by the user?

you can add to check something like this:

--Few checks if it's a not hidden script, aka. made in workspace/startergui/etc.
local toCheck = {workspace, game.Lighting, game.StarterGui} --You can add more here.

for u,c in pairs(toCheck) do
	for i,v in pairs(c:GetDescendants()) do
		if v == inst then
			print("Script is made by player in "..c.Name)
		end
	end
end
1 Like