Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 9 years ago

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

Log in to vote
1
Answered by 9 years ago

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.

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 JasonTheOwner 391 — 9y
Ad

Answer this question