Creating global owner variable like Void Script Builder with fenv?

Hello devs, I was trying to figure this out for loong time and I don’t know on how do I use fenv to set global owner variable like Void Script Builder because I wan’t to create my own script builder, and I don’t have any experience with fenv. So how do I do it?

getfenv() returns a table of the environment of the current scope
If you don’t pass any parameters then it will get the environment of the entire script or the function it’s ran in (correct me if I’m wrong)

you can do something like

print(variable1) --> nil
getfenv().variable1 = 'get real'
print(variable1) --> get real

Or in the case of loadstrings, there’s 2 ways:

local append = [[
  getfenv().variable1 = 'GETTING REAL'
]]
local lscript = [[
  print(variable1)
]]
loadstring(append..lscript)() --> GETTING REAL

or

local lscript = [[
  print(variable1)
]]
local lfunc = loadstring(lscript)
getfenv(lfunc).variable1 = 'GETTING REAL'
lfunc() --> GETTING REAL

Finally a propper explanation for this, Thank you! I understand this now!