Hi! I’m using OrderedDataStores for global leaderboards, but from what I’ve researched, OrderedDataStores cannot sort data when given something such as:
{
["Stats"] = {
["Money"] = 500;
["Gold"] = 10;
["example"] = 0;
};
};
So I have set up a second DataStore, which is a OrderedDataStore, but I’m curious as to what the best method of saving to this is. Currently, whenever I initialize a player’s data upon joining, I start a loop that uses :SetAsync on the OrderedDataStore every 3 minutes:
delay(0, function()
while wait() do
if (player) and module.LoadedPlayers[player] then
local money = module.fetchData(player, "Stats", "Money")
MoneyOrderedStore:SetAsync(tostring(player.UserId), money)
wait(180) -- Put here so it updates as soon as a player joins.
else
break
end
end
end)
Is there a better method of doing this? Any help is awesome, thank you.