Skip to content
Saiko

debug.getconstant

Returns the constant at a given index inside a function.

Signature

luau
debug.getconstant(fn: function | number, index: number): any

Parameters

fnfunction | number

The function, or a stack level.

indexnumber

1-based constant index.

Returns

any

Example

luau
local function login()
    return "token-123"
end

print(debug.getconstant(login, 1)) --> token-123