Scripts

getrunningscripts

Returns a new array table of unique script Instances taken from live Lua threads.

Syntax

getrunningscripts(): table

Returns

NameTypeDescription
scriptstableNew array table of unique script Instance object values associated with live Lua threads.

Description

Returns a new array table of unique script Instances taken from live Lua threads. The function takes no arguments. It walks the live Luau thread list, reads each thread node, skips entries without a thread node, without a weak thread ref, without LiveLuaRef, without a Lua state, without object, or with an expired Script stored reference. For each remaining thread, it locks scriptThread->object->Script(), deduplicates by the script reference, pushes the Instance with Instance cache, and inserts it at sequential array indexes starting at 1. The function does not scan the DataModel, does not check ClassName, and does not sort the result.

Call it without parameters. The function reads the needed context from the current runtime state.

It returns scripts (table). Use the returns table to separate successful values from nil results and recoverable errors.

Example

Example call with placeholder values.

local result = getrunningscripts()
print(result)