Hey, I've used the default ordered datastore from the wiki as an example, but it won't grab the the key when I insert mine. The default example works perfectly.
Here's a few snippets of my datastore saving and retrieving.
local tokensKey = ds:GetAsync("Key1" .. newPlayer.Name)
if tokensKey then
tokens.Value = tokensKey
else
tokens.Value = 0
end
tokens.Changed:connect(function(save)
ds:SetAsync("Key1" .. newPlayer.Name, save)
end)
It all saves and retrieves fine, I've got a GUI set up to display it. But when it comes to displaying on the physical leaderboard it doesn't show any info...
local ods = game:GetService("DataStoreService"):GetOrderedDataStore("dataone")
function updateBoard(board, data)
for k,v in pairs(data) do
local pos = k
local name = v.Key1
local score = v.value
local nametextbox = board.SurfaceGui:FindFirstChild("Name" .. pos)
nametextbox.Text = name
local scoretextbox = board.SurfaceGui:FindFirstChild("Score" .. pos)
scoretextbox.Text = score
end
end
while true do
-- wrap logic in pcall in case datastore request fails
local success, message = pcall(function()
local pages = ods:GetSortedAsync(false, 5)
-- get data for first board
local data = pages:GetCurrentPage()
updateBoard(game.Workspace.Top5ScoreBoard, data)
-- check if another page of data exists
if not pages.IsFinished then
-- if so then get data for second board
pages:AdvanceToNextPageAsync()
data = pages:GetCurrentPage()
updateBoard(game.Workspace.Next5ScoreBoard, data)
end
end)
if not success then
print(message)
end
wait(2)
end
