Getfenv() behaving oddly

I want to access the environment variables that are at higher level than the environment of the current function called. I do this by using getfenv(#). For unknown reasons, it is behaving very oddly although it had worked just few days ago under the same measure. I expected it to return the environmental variables, but it instead returned only the basics.
image
image
image

Here is the sample code for observance.

local ak = "bl"

local a = getfenv(1)
print(a)

To prevent confusion, I am having this same issue for another code which is a module accessing the higher level of another module.
image

Indexed STRUCT_EVENT in backup but returns nil although still only has the basics: _G, script, and shared.

I’ve tried attempts to study what’s going on in Getfenv() across three kind of scripts: local, server, and module. Every of them still has Getfenv() behaving oddly either way no matter the case. Are there any flaws in the usage of Getfenv() according to the codes provided? Much thanks. Obrigado. Hvala.

For this unfortunately you cannot access local variables only global variables without the local.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.