debug.getsafeenv
Returns whether a function, table or thread has a safe environment.
Syntax
debug.getsafeenv(target?: any) -> boolean
Parameters
| Parameter | Type | Description |
|---|---|---|
target? | any | The function or object being targeted. |
Returns
| Type | Description |
|---|---|
boolean | Whether a function, table or thread has a safe environment |
Description
debug.getsafeenv 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 call is read-only: it resolves the current value when invoked and does not change the underlying state.
The aliases isuntouched(target?), getsafeenv(target?) resolve to the same implementation.
Example
print(debug.getsafeenv(function() end))
Notes
- Aliases:
isuntouched(target?),getsafeenv(target?). - Writing protos, constants or upvalues can corrupt a running function; test changes carefully.