ReferenceEnvironment

getallthreads

Lists every live thread in the current game state, including suspended and waiting ones.

Syntax

getallthreads() -> {thread}

Also available as

get_all_threads

Returns

TypeDescription
{thread}Every thread that currently exists in the game's Luau state.

Description

Each game script runs on at least one thread, and every task.spawn, task.delay and coroutine adds more. Use it with gettenv, getcallstack or getscriptfromthread to see what is running.

Example

for _, thread in getallthreads() do
    local script = getscriptfromthread(thread)
    if script then
        print(script:GetFullName(), coroutine.status(thread))
    end
end

Notes

These are Game executor contracts. Check build requirements and session lifetimes before using them.