How Do I Efficiently Get All the UserIds of the Players that Played My Game?

I’m trying to take a record on every new person who joins my game, and I have a problem, how do I get it?

I’ve thought of putting them into one datastore, which was a pretty good idea. But, it has a limit of 260k characters, and assuming each UserId is 10 characters long, 26k unique players would put a cap on the limit. Using another datastore would be too much work, and would make things messy and inefficient.

The last way, which is the most efficient way I could think of, is to use OrderedDataStores. Then, I can get each player who joined my game(never used OrderDatastores, but they can be used for leaderboards, so I’m assuming you can get UserIds that way).

The question is, how do I get the UserId from an OrderedDataStore?

1 Like

You need to use a database to do that, like Firebase. Take a look here

I was talking about OrderedDataStores, not a custom open sourced module. OrederedDataStore is provided by Roblox.

Take a look here for a reference on OrderedDataStores. I don’t know what you want from us.

Is there a reason why you would need to record every new player that plays your game? Anyway, it is possible with OrderedDataStores, you just need to learn how they work.

@WooleyWool @COUNTYL1MITS
The sole purpose of this is so that I can get the data from all the users that played my game so I can load their data later. I have read the documentation, but I’m still confused on how I can get the players UserId from its return value (from GetSortedAsync):

local DataStoreService = game:GetService("DataStoreService")
local PointsODS = DataStoreService:GetOrderedDataStore("Points") 
 
local function printTopTenPlayers()
	local isAscending = false
	local pageSize = 10
	local pages = PointsODS:GetSortedAsync(isAscending, pageSize)
	local topTen = pages:GetCurrentPage()
 
	-- The data in 'topTen' is stored with the index being the index on the page
	-- For each item, 'data.key' is the key in the OrderedDataStore and 'data.value' is the value
	for rank, data in ipairs(topTen) do
		local name = data.key
		local points = data.value
		print(data.key .. " is ranked #" .. rank .. " with " .. data.value .. "points")
	end
 
	-- Potentially load the next page...
	--pages:AdvanceToNextPageAsync()
end

That’s the provided example, doesn’t provide how to get the UserId.


On second thought, I can try getting the UserId by setting the data key to the players UserId:

local name = data.key -- "key" would be the datastore key I use for the player

:GetCurrentPage() returns a dictionary where the keys are the indexes and data are the values.