OrderedDataStore - Problem with tables/Arrays

Hello,

I need help about dataStore and especially about GetOrderedDataStore().
I have a dataSaved as a table (In the 1st script named “dataToSave”) and i need to order just 1 of the 3 value in my table how can i do that (The value that i need to oreder is the dataToSave[1] (for after make a global leaderboard?

Here is the script that is used to manage dataStore

-- << 	Services >> --
local DataStoreService = game:GetService("DataStoreService")
-- << 	Variables >> --
local dataStore = DataStoreService:GetDataStore("MyNewData")
-- << Functions >> --
local function saveData(player)
	local dataToSave = {
		player.DataRepertory.BetterTime.Value;
		player.DataRepertory.LastTime.Value;
		player.DataRepertory.WorseTime.Value
	}
	
	local success, err = pcall(function()
		dataStore:SetAsync(player.UserId, dataToSave)
	end)
	
	if success then
		print("Data has been saved !")
	else
		print("Data hasn't been saved !")
		warn(err)
	end
end

here is a part of the second script about orderedData

-- << 	Services >> --
local DataStoreService = game:GetService("DataStoreService")
-- << 	Variables >> --
local scoreForLeaderboard = DataStoreService:GetOrderedDataStore("MyNewData")
-- << Functions >> --
local success, errorMessage = pcall(function()
	local Data = scoreForLeaderboard:GetSortedAsync(true, 10)
	local topTEN = Data:GetCurrentPage()
)

Thanks, if u need any things in more tell me

I’m not too experienced on the topic but you should check this out, it might help :

1 Like

Thanks, i already seen this topic and i rechecked it, but it doesn’t containt my answer.
My question is just how can i “separe” my 3 value stored in the dataSTore, for after Ordered just 1 of the 3 data.
Or do i need to stock this data separately from the 2 others?

1 Like