debug.getcallstack Synchronous

  • getcallstack

Capture visible Luau frames from a coroutine. Use it to print a compact stack trace with function references and current line numbers.

Syntax
Luau
debug.getcallstack(targetThread: thread?) -> {{func: Function, currentline: number?}}

Parameters

Function parameters
ParameterTypeDescription
targetThreadthread?Optional coroutine to inspect; the current one is used by default.

Returns

{{func: Function, currentline: number?}}

An array of records with func and currentline fields.

Example

Example
Luau
local function showFrames()
    for depth, frame in ipairs(debug.getcallstack()) do
        print(depth, frame.currentline, debug.getinfo(frame.func).source)
    end
end
showFrames()
Kawaii documentation