debug.setsafeenv
Marks a function, table or thread environment as safe or unsafe.
Syntax
debug.setsafeenv(target?: any, safe?: boolean) -> nil
Parameters
| Parameter | Type | Description |
|---|---|---|
target? | any | The function or object being targeted. |
safe? | boolean | The safe value used by the call. |
Returns
| Type | Description |
|---|---|
nil | This function does not return a value. |
Description
debug.setsafeenv is part of the Debug library. The debug library exposes the internals of the active Luau state, including protos, constants, upvalues and stack frames.
The change is applied directly to the live target, so later reads observe the updated value.
The aliases setuntouched(target?, safe?), setsafeenv(target?, safe?) resolve to the same implementation.
Example
local env = getfenv(0)
debug.setsafeenv(env, false)
print(debug.getsafeenv(env)) -- false
Notes
- Aliases:
setuntouched(target?, safe?),setsafeenv(target?, safe?). - Writing protos, constants or upvalues can corrupt a running function; test changes carefully.