This prints 5 and then 6. It's supposed to add 1 to any variable set, so a
should be 6 and b
should be 6, but __newindex
doesn't affect a
because it was declared locally. Is there any way to filter local variables?
do local e={print=print} setfenv(1,setmetatable({},{ __index=function(t,k) return e[k]or loadstring('return '..k)() end, __newindex=function(t,k,v) e[k]=v+1 end })) end local a=5 print(a) b=5 print(b)
Local variables can't be found unless you're using the debug library; here But it's useless in ROBLOX.