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?
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.