How can I get Ordered DataStore for a stored table?

Hi Guys, so basically I was trying to create a time leaderboard and I suddenly ran into a problem where I had a DataStore in which I stored table values, not integeral values. Now I want to get Ordered DataStores without create more DataStores or scopes for each item in the table. How can I possibly do that?

Any help is very much appreciated. Thanks :slight_smile:

When you got variable of your stored table you can get values from it like that:

local playerTime = {Hours = 10, Minutes = 30} -- table variable
print(playerTime.Hours) -- print "10"
print(playerTime.Minutes) -- print "30"

Hope I helped you!

1 Like

Hey, thanks for your answer, but I want to get Ordered DataStores for table values. Sorry but I dont really understand how this code could help me. Can you explain it by example to me? That would help me alot :slight_smile:

Can you please provide an example of the table you storing in datastore? And how you can get it in result?

The table Iā€™m using -

{
Stage = 0,
TimePlayedInSeconds = 0, -- this is the value I want to get OrderedDataStore of
RobuxSpent = 0,
}

Just Simply Retrieve the table and get the data inside.

local data = -- get ur data with get sync
if data then
print(data.TimePlayedInSeconds)
end

How do I make it ordered, like getting the top 10 players globally for the TimePlayedInSeconds value?

Here is an example:

dataStore:GetSortedAsync(smallestFirst, numberToShow, minValue, maxValue)

smallestFirst: show smallest numbers first (boolean)
numberToShow: how many players will show on leaderboard (number)
minValue: minimum value to show on the leaderboard (its usually a huge number) (number)
maxValue: maximum value to show on leaderboard (number)

a topic that will help:
How to make a simple global leaderboard - Resources / Community Tutorials - Developer Forum | Roblox

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.