Try this: ~~~ file localisglobal.lua setmetatable(_ENV,{__newindex = function (ENV,name,value) if name:match"^%a%d?$" then print(": A global name like '"..name.."' is asking for trouble") end rawset(ENV,name,value) end}) local Y=2 ~~~