Similarly, any object stored in a global variable is not garbage for Lua, even if your program will never use it again. In both cases, it is up to you (i.e., your program) to assign nil to these positions so that they do not lock an otherwise free object.
However, simply cleaning your references is not always enough. Some constructions need extra collaboration between you and the collector. A typical example happens when you want to keep a collection of all live objects of some kind (e.g., files) in your program. That seems a simple task: All you have to do is to insert each new object into the collection. However, once the object is inside the collection, it will never be collected! Even if no one else points to it, the collection does. Lua cannot know that this reference should not prevent the reclamation of the object, unless you tell Lua about that.
Weak tables are the mechanism that you use to tell Lua that a reference should not prevent the reclamation of an object. A weak reference is a reference to an object that is not considered by the garbage collector. If all references pointing to an object are weak, the object is collected and somehow these weak references are deleted. Lua implements weak references as weak tables: A weak table is a table where all references are weak. That means that, if an object is only held inside weak tables, Lua will collect the object eventually.
When you do a = 5 (global) you are actually doing _G.a = 5. The environment is simply a table and all the globals are stored in _G. Roblox has changed this for security reasons though and the defualt environment is locked away.
Here it is referring to storing references in tables. Even though an object might not have any more “references” the table still contains a reference to it therefore it won’t get garbage collected.
This is where weak tables come in. A table’s keys and/or values can be weak. If the only references to an object are weak then the object will become eligible for garbage collection. So you could store objects in a weak table and they would get gc’d when there are no more strong references to them.
Roblox doesn’t seem to have changed anything in this regard.