debug.getconstants

Reads a function's constants.

Syntax

Signature
debug.getconstants(FunctionOrLevel: function | number) -> table

Aliases

This function has no aliases.

Parameters

ParameterTypeDescription
FunctionOrLevelfunction | numberLuau closure or positive stack level.

Returns

TypeDescription
tableConstant slots indexed from 1. Some indexes may be absent.

Notes

Returns the selected Luau function's constant slots in a table using one-based indexes. Nil, table, and function constants are returned as nil, so the result can have holes. A positive stack level may be used in place of a function.

Example

Luau
local Function = function() local Message = "Hello" return Message end
local Result = debug.getconstants(Function)
print(Result)