This question is pretty straightforward, and I'm asking it just to be safe. Is there any reason to do garbage collection on the client as the player is leaving the game? For example if a local script is running on the client tracking playerdata, should I worry about ending that process as the player leaves the game?
Any variables held by a LocalScript is being ran BY the client, thus, a player leaving the game not only removes the variables, but also the VM so you shouldn't worry about any garbage leftover.
The local script will be destroyed anyways when they leave.
Suppose you have a session table:
local session_data = { } -- when they join... session_data[player] = { } -- table of their data -- when they leave... save_data(player, session_data[player])
If you don't clear their index when they leave this could cause potential memory leak. You still have a reference to the player which is the key. You don't need to keep the data around when they leave anyways.
session_data[player] = nil
But don't worry about efficiencies or optimizations too much.
#1 rule of optimization: Don't do it. #2 rule of optimization: Don't do it yet.