What do you want to achieve? I am looking to fix this problem I am having with my OrderedDataStore
What is the issue? I am trying to create a leaderboard by using an OrderedDataStore. I write to it using UpdateAsync() and inside that function I confirm that the value are infact being updated. The problem is when I try to read from the DataStore it says the key and value are both nil.
What solutions have you tried so far? Ive done a lot of print debugging and I cant figure out the problem.
local TreasuresFoundLeaderboardDataStore = DataStoreService:GetOrderedDataStore("TestingLeaderboardDataStore", "TreasuresFound") -- This is the portion that reads from the data store. local DataStorePages = TreasuresFoundLeaderboardDataStore:GetSortedAsync(false, 9, 1, math.huge) local CurrentPage = DataStorePages:GetCurrentPage() if #CurrentPage > 0 then for Index, Object in pairs(CurrentPage) do print(Object.Key, Object.Value) -- It prints nil,nil end else end -- This is the portion that writes to the data store. local Success, ReturnedArgument = pcall(function() TreasuresFoundLeaderboardDataStore:UpdateAsync(Player.UserId, function(OldValue) local NewValue if OldValue == nil then NewValue = 0 else NewValue = OldValue end NewValue = NewValue + 1 print(NewValue, OldValue) -- This prints the correct information, so I assume it is correctly updating. return NewValue end) end) print(Success, ReturnedArgument) -- This prints True, nil so it isnt throwing an error.
Thanks and hopefully someone can help me out! Have a good one!