function Load() CurrentBase = game.Workspace.Baseplate CurrentBase.BrickColor = BrickColor.Random() end for i, v in pairs(getfenv(Load)) do print(i,"=",v) end
It should returns a table with the load function containing their variables but it doesn't do
Anyone help plz?
The env of the Load
function is the same as the env of the script, so you don't have to specifically get that function's env.
And the reason it doesn't print the CurrentBase
variable is because you never call the function so it never sets it.
Also don't confuse the behaviour of getfenv()
. It doesn't return all variables used by a function, but rather its env, where all global variables are stored.