Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can I get a list of all scripts running in my place?

I want to get a list of all scripts running in my place to monitor if any have been injected. Any ideas how I can get such a list?

1 answer

✓ Accepted answer

This is kind of hard to do. You'll have to use a recursive function, which is a function that calls its self.

Try this:

PLACES_TO_SEARCH = {
	game.Workspace,
	game.Players,
	game.Lighting,
	game.ReplicatedFirst,
	game.ReplicatedStorage,
	game.ServerScriptService,
	game.ServerStorage,
	game.StarterGui,
	game.StarterPack,
	game.StarterPlayer
}

scriptsInGame = 0;

function search(par)
	local children = par:GetChildren();
	for i, child in ipairs(children) do
		if(child:IsA("Script") or child:IsA("LocalScript") or child:IsA("ModuleScript")) then
			scriptsInGame = scriptsInGame + 1;
		end

		local grandChildren = child:GetChildren();
		if(#grandChildren > 0) then
			search(child);
		end
	end
end

for i, v in ipairs(PLACES_TO_SEARCH) do
	search(v);
end

print(scriptsInGame);

Please note that you can't just do search(game), or else you will get some unknown error.

If this lags your game a lot, you might consider adding some wait() calls in the loops.

Hope this helped, ProtectedMethod.

1 comment

0

Its an interesting idea. I was hoping something else existed as a roblox service call. In studio, running in server/client mode, one of the windows you can have open lists all the scripts and their performance (I think its the performance view). I wonder if the mechanism that gets us this view can be accessed to monitor script performance in game, as well as what scripts are running. If I have

This discussion is preserved as it was. New answers, comments, and votes are closed.