How do i get a non modified Environment?

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)```

What exactly do you mean by an environment that won’t be modified by the original environment? What’s the purpose for this?

You can just set up a custom table of environment items:

local env = { ["print"] = print, ["setfenv"] = setfenv } setfenv(1, env) setfenv(0, env) 

Its for experimenting and it needs to be an actual environment. I cannot create a custom one as the code underneath the checks can change.

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.

I meant environment as in whatever getfenv will return.

local newEnv=setmetatable({},{__index=_G}) newEnv.lol='lol' local function getNewEnv()return(newEnv) end getfenv().lol='modified' warn(getNewEnv().lol) warn(getfenv().lol)