[PLUGIN] I'm trying to get the metatable of a script's function environment, but I haven't found a perfect way yet. cntkillme was of great help to me but I need to be able to get the metatable of the function environment to have access to the user-defined values.

This is what I have so far:

local function getSenv(arg)
	local func = setfenv(loadstring(arg.Source), setmetatable({arg}, {__index = getfenv(0);}));
	local argEnv = getfenv(func);

	return argEnv;
end