AcediaDocumentation

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

ParameterTypeDescription
targetLuaSourceContainerScript container to inspect.

Example

local target = game:FindFirstChildWhichIsA("LocalScript", true)
if target then
    local ok, env = pcall(getsenv, target)
    print(ok, type(env))
end

Example output

true	table

Errors: A non-Actor script without a reachable running or remembered environment raises "the script is not running".

On this page