Update misc.lua

If the _G metatable is protected then that code will error, so I've put a check to see if it is and stops the code from running.