And I'm back with yet another data store question.
This time, I'm trying to make a leaderboard for my game, but it doesn't seem to show any data because whenever it tries to retrieve data from the data store, there seems to be no data, yet I've previously saved some before. All the following code takes place on the server side:
local DataStoreService = game:GetService("DataStoreService") local playTimeData = DataStoreService:GetOrderedDataStore("PlayTimeData") pcall(function() playTimeData:SetAsync(userid, v) -- userid is the player's UserId, and v is the value to be saved (how I obtain these values is not shown in here, although I can 100% verify that I am able to obtain these values without problems) print(userid) -- This... print(v) -- ...and this had printed values without problems, and no data seemed abnormal end) -- Now getting the data from the same data store local pages = playTimeData:GetSortedAsync(false, 50) local top = pages:GetCurrentPage() -- The for loop to check for these values for i,v in pairs(top) do if v ~= nil then print(i) print(v) else print("Nil value found!") end end -- This for loop didn't print anything, nor did it output errors, implying that there was no data in the data stores
(Note: I'm only showing part of the code that I need to fix, not the whole script which deals with the leaderboard.)
What have I done wrong this time...?