> setfenv(0,setmetatable(g, {__index=_G})) I believe you meant 1 instead of 0. From the manual: > Level 1 is the function calling setfenv. > As a special case, when f is 0 setfenv changes the global environment of > the running thread. -- Roberto