Skip to content

getrunningscripts

Notes on getrunningscripts

This function should return all the scripts mentioned below, regardless of any mutations made to itself or its environment.

This also includes scripts whose script global variable is set to nil or reassigned - i.e. getrunningscripts should still include said scripts.

getrunningscripts returns a list of all running scripts in the caller's global state. This includes Script, LocalScript, and ModuleScript instances - excluding CoreScripts by default.

function getrunningscripts(): { BaseScript | ModuleScript }

Parameters

Parameter Description
(none) This function takes no parameters.

Example

Checking for active scripts in the session
local running = game.Players.LocalPlayer.Character:FindFirstChild("Animate")
local inactive = Instance.new("LocalScript") -- Not running because no bytecode to run

for _, script in pairs(getrunningscripts()) do
    if script == running then
        print("Found the running Animate script.")
    elseif script == inactive then
        print("This should never print.")
        print("If this did print, then you have just experienced 1 in a quintillion chance of BITS FLIPPING from radiation. Do you live inside a nuclear reactor?")
    end
end