getsenv
Returns the environment associated with a script's thread.
Prefers a running thread with the correct script binding and can reuse a remembered environment. An unreachable Actor script environment returns nil.
getsenv(target: LuaSourceContainer): table?Parameters
| Parameter | Type | Description |
|---|---|---|
target | LuaSourceContainer | Script container to inspect. |
Example
local target = game:FindFirstChildWhichIsA("LocalScript", true)
if target then
local ok, env = pcall(getsenv, target)
print(ok, type(env))
endExample output
true tableErrors: A non-Actor script without a reachable running or remembered environment raises "the script is not running".
