Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

setfenv() stack level don't work?

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?

2 comments

0

Any errors?

0

No.

1 answer

✓ Accepted answer

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.

1 comment

0

So, How I will get the variables of the function?

This discussion is preserved as it was. New answers, comments, and votes are closed.