Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

setfenv() stack level don't work?

Asked by 6 years ago
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?

0
Any errors? MrGaming4me 28 — 6y
0
No. Xx_XSanderPlayXx 160 — 6y

1 answer

Log in to vote
0
Answered by
Amiaa16 3227 Moderation Voter Community Moderator
6 years ago

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.

0
So, How I will get the variables of the function? Xx_XSanderPlayXx 160 — 6y
Ad

Answer this question