Debug libraryOverview
debug.setupvalue
Represents modification of a captured closure value.
Aliases
setupvalueDetails#
Changes a captured value by one-based index in a Luau closure. Closures sharing the capture may observe the change. A function without upvalues or an invalid index raises an error; inspect captures before selecting an index.
Examples#
Example
local state = { count = 3 }
local function read() return state.count end
debug.setupvalue(read, 1, { count = 7 })
print(read()) -- 7