Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

What are ORDERED data stores?

Asked by
NotSoNorm 777 Moderation Voter
8 years ago

I know Data Stores themselves, Can anyone explain how 'ordered' data stores work though? I'm not asking for a script, just an explanation.

1 answer

Log in to vote
3
Answered by
Kurieita 125
8 years ago

"OrderedDataStore is a type of DataStore where the value must be an integer (positive number). This is done in order to create a way to easily order key/value pairs, making it suitable for leaderboard related scripting where you are required to order large amounts of data efficiently. For example, you can write a script that shows the top 100 high scores in your game. "

OrderedDataStore work much like DataStore. The only different is that OrderDataStore return a table of, well a DataStore but in a order. For Example, 'highscores'

local OrderDataStore = Game:GetService('DataStoreService'):GetOrderedDataStore('HighScore')
local Pages = OrderDataStore:GetSortedAsync(false,  5)      
local Data = Pages:GetCurrentPage()             
for Key, Value in pairs(Data) do                                    
    print(Key .. ": " .. Value )    
end

That would print out the greatest amount of points to the lease.

OrderDataStore order the data by integers.

Accept and upvote :)

Ad

Answer this question