Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Help on using datastore pages?

Asked by 2 years ago

I'm making an auto-updating leaderboard for an obby game. I already have a working timer script that records times onto a datastore. I'm trying to sort it using an ordered datastore. It doesn't seems to print anything when I test it.

local DataVersion = "2"
local DataStoreService = game:GetService("DataStoreService")
local SpeedrunTime = DataStoreService:GetOrderedDataStore(DataVersion.."SpeedrunTimer")

function updateLB()

    local sorted = SpeedrunTime:GetSortedAsync(true,25)
    local entries = sorted:GetCurrentPage()

    for _, entry in pairs(entries) do
        --for each of the top 25 runs it does thing
        print(entry.key .. " : " .. tostring(entry.value))
        script.Parent.SurfaceGui.TextButton.Time.Text = entry.value
    end

end



updateLB()

while wait(60) do
    pcall(function()
        updateLB()
    end)
end

Answer this question