Are tables and connection garbage collected if the script is destroyed?

Are tables and connection garbage collected if the script is destroyed?

1 Like

I do not know, but this is what tutorialspoint.com says:

Lua uses a garbage collector that runs from time to time to collect dead objects when they are no longer accessible from the Lua program.

This supposedly means that after your script is destroyed, the tables and connections are ‘dead’, since they are no longer accesible from your active Lua threads. So I am guessing that the answer is yes, but I do not know for sure.

Also, the garbage collection is done every frame if I am correct (see Task Scheduler | Roblox Creator Documentation).

It depends on the Lua references inside your script.