VINDICTA
Debug · Library
Bunni.fun
ChocoSploit
Cryptic
Potassium
Seliware
SirHurt
Solara
Velocity
Volcano
Volt
Wave
Xeno

debug.getconstants

Returns the full constant table of a function.

function debug.getconstants(func: function | number): {any}

Synopsis

How it works

Returns the entire Proto.k[] array as a Lua table. Each element corresponds to a constant slot in the bytecodeBytecodeThe compiled binary representation of Luau source code. A sequence of 32-bit instructions (opcodes + operands) stored in a Proto's code[] array. Executed by the Luau VM interpreter.. The table may be sparse — some indices hold nil (for LUA_TNIL constant slots), so iterate with pairs() instead of ipairs().

Relation to instructions

Every constant-referencing opcode (LOADK, GETGLOBAL, NAMECALL, GETTABLEKS) stores an index into this array. Dumping the full table reveals all string literals, global names, and numeric constants a function uses without decompilingDecompilerA tool that converts compiled bytecode back into readable Luau source code. Not a perfect inverse — variable names, comments, and some control flow structures are lost during compilation..

Usage

Dump constants
local function foo()
	local num = 5000 .. 50000
	print("Hello, world!", num, warn)
end
for i, v in pairs(debug.getconstants(foo)) do
	print(i, v)
end

Parameters

func function | number
A Luau function or stack level.

Returns

{any} Sparse table of constants.