debug.getinfo
Returns debugger information about a function or stack level.
function debug.getinfo(func: function | number): DebugInfoSynopsis
How it works
Returns a table of debug metadata extracted from the closureClosureA function value that captures its lexical environment. In Luau, closures come in two types: LClosure (Luau bytecode + Proto + upvalues) and CClosure (native C function pointer + upvalues).’s
Proto struct (Luau) or lua_CFunction metadata (C closures).Fields — Luau closures
For
For
LClosures, the data comes from the Proto and its debug info:
| Field | Source | Example |
|---|---|---|
source | Proto->source | "=Players.Player.PlayerScripts.Script" |
short_src | Truncated source | "[string "...""]" |
name | Debug name hint | "onCharacterAdded" |
numparams | Proto->numparams | 2 |
nups | Proto->nups | 3 |
is_vararg | Proto->is_vararg | 1 |
currentline | PC → line mapping | 42 |
CClosures, only source = "[C]", what = "C", and name are available.Usage
Inspect a function
local function foo()
print("Hello, world!")
end
for k, v in pairs(debug.getinfo(foo)) do
print(k, v)
endParameters
func function | number A Luau function or stack level.
Returns
DebugInfo Table of debug metadata fields.