how do I get a roblox lua environment (getfenv) that will not get modified by the original environment? Here is what i tried, but non of them worked:
getfenv().lol = 'lol' -- not allowed to add code above this or remove this.
local Environments = {
getfenv(0),
getfenv(nil),
getfenv(1),
select(2, pcall(getfenv, 0))}
local DebugFuncs = {}
for i = 1, 10000 do
pcall(function(...)
local Dbg = debug.info(i, 'f')
if Dbg then
table.insert(DebugFuncs, Dbg)
end
end)
end
for i, v in next, Environments do
warn(v.lol)
end
for i,v in next, DebugFuncs do
warn(getfenv(v).lol)
end
local NameCall
xpcall(function(...)
return game:GetService('ioasdfhp')
end, function(a0)
NameCall = debug.info(2, 'f')
end)
warn(getfenv(NameCall).lol)```
I would also like for you to elaborate on what this means. An environment contains all of the identifiers that are bound in the current scope, so if you bind a new identifier (e.g. make a local variable) then that will update the current environment.
If you want to create a snapshot of the current environment that will not be modified with new identifiers, then you could copy the current environment into a separate table.