UPDATE: I totally overthought the question, but if you want some neat information about Lua internals, it’s below I suppose.
When you write Main = nil, you’re not clearing the table from memory, you’re just clearing the reference. If there’s no references left, the table will be deleted from memory. setmetatable counts as a reference.
I’d love for someone who knows more about the internals of Lua to correct me on what I misinterpret/get wrong, but here’s my understanding.
In lua_setmetatable (the C function responsible for setting the metatable), this line tells Lua to cross an object over the Lua/C barrier.
The only reason I tested in standard Lua is because Roblox Lua does not allow the use of collectgarbage(). Yes, weak tables work just fine in Roblox Lua.
collectgarbage("count") will only show you how much memory is being taken. collectgarbage() actually forces a garbage collection cycle.