How to get a list of all players that have ever played the game?

I’d like to create a system that allows me to print off the UserID of every player that has ever played the game. However, I’m not sure how to accomplish this.

I’ve considered adding the player’s UserID to a datastore when they join and using ListKeysAsync() to get the info, however this has a large issue: The datastore will run out of storage. Datastores can only store 4 MB of info. Considering that one character is 8 bytes, and the average userID is 10 characters, this would mean only 50,000 players could join before the datastore would run out of storage.

So, my question is:
How can I create a system that stores the UserID of every player that has ever joined the game?

Thanks! :smile:

4 Likes

I believe that in Lua–or at least in Roblox Lua–characters in a string are only 1 byte, if thats true you could store the UserID as a string instead.

It would still be limited to 1 million players, though.

1 Like

just make a simple DataStore and save each any value to it like timestamps such as tick() if you need to calculate when they first joined or last time they joined, as for the limit of 4 mb its per key not per datastore.

Source

1 Like

Like others said, you misunderstood the info size limit. It’s for one key in the datastore, so you could just save tables of user IDs. How will you prepare for those tables reaching 4MB (hundreds of thousands of ids if I’m correct) it’s up to you. Maybe something like saving those tables in your own pages (“UserIds1”, “UserIds2”, etc) or something like that.

1 Like

you could easily use multiple data stores, for instance once one hits 1 million, start using another data store

1 Like

TBH, I don’t really know how the datastore service works because I’ve never used it before lol

2 Likes

honestly i would suggest just creating a badge given to players upon joining. you would have to make a method for calling the owners though

3 Likes

Badges can be deleted by the player.

Create a new key per player, and use listkeysasync.

You will be more likely to hit rate limits with this approach though, but it would be more reliable than attempting to update a key with a table of user IDs which might be accessed on multiple servers unless you want to implement session locking.

2 Likes