Scripts & runtimeOverview
getmenv
Represents inspection of a module script environment.
Details#
Resolves a ModuleScript environment and may require the module if it has not yet executed. This can run the module body and trigger its side effects. Returns nil when the input is not a usable ModuleScript or no environment can be recovered.
Examples#
Example
local ownModule = Instance.new("ModuleScript")
local ok, environment = pcall(getmenv, ownModule)
print(ok, environment) -- an empty new module has no executable body
ownModule:Destroy()