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.
Luau
debug.getcallstack(targetThread: thread?) -> {{func: Function, currentline: number?}}Parameters
| Parameter | Type | Description |
|---|---|---|
targetThread | thread? | 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
Luau
local function showFrames()
for depth, frame in ipairs(debug.getcallstack()) do
print(depth, frame.currentline, debug.getinfo(frame.func).source)
end
end
showFrames()