Skip to content
Debug libraryOverview

debug.getupvalues

Represents inspection of captured closure values.

Aliasesgetupvalues

Details#

Returns captured values indexed from 1 for a Luau function or positive stack level. Values referencing tables remain shared. Nil slots create holes, so pairs is more appropriate than relying on the table length.

Examples#

Example

Luau
local state = { count = 3 }
local function read() return state.count end
for index, value in pairs(debug.getupvalues(read)) do
    print(index, type(value))
end