Universal Lobby System Problem

I have a universal lobby system that works between all servers using MessagingService and DataStoreService.

When a player creates a lobby it will teleport them to a private server and then save the server information with DataStore. Then when that lobby is closed which I indicate with game:BindToClose() I update the DataStore that the server is closed and it is removed from the table of active lobbies.

But the problem I am having with the current system is that if you create a lobby ifr updates the datastore but if you leave before teleport service finishes teleporting you it will create the lobby but since the player never teleports to the lobby server the game:BindToClose() will never fire which never removes the lobby from the datastore creating a memory leak of increasing inactive lobbies.

If anyone has any idea that would be nice, I was thinking of just creating a scrubber that scans through the list of active servers and checks if there are any empty servers and if so remove them from the datastore but this seems semi-inefficient and was curious to as if anyone had a better method.

Thanks! :smiley:

Maybe run a loop every set hour say every one hour and close any lobbies that have no players in it?

1 Like

That would work but I think I’m gonna put the code that saves the lobby information in the lobby server so that it can’t save until the server opens

1 Like