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

OrderedDataStore Script Not Working?

Asked by
TofuBytes 500 Moderation Voter
10 years ago

I'm trying to get a global leaderboard working, but it doesn't seem to be popping up. Can I get some help on what I did wrong? I'm trying to get leaderstats "Coins" from the player.

local ods = game:GetService("DataStoreService"):GetOrderedDataStore("Coins_Stats")

function updateBoard(board, data)
    for k,v in pairs(data) do
        local pos = k
        local name = game.Players.LocalPlayer
        local score = game.Players.LocalPlayer.leaderstats.Coins.Value
        local nametextbox = game.Workspace.Leaderboard.SurfaceGui:FindFirstChild("Name" .. pos)
        nametextbox.Text = name
        local scoretextbox = game.Workspace.Leaderboard.SurfaceGui:FindFirstChild("Score" .. pos)
        scoretextbox.Text = score
    end 
end

while true do
    local pages = ods:GetSortedAsync(false, 5)
    local data = pages:GetCurrentPage()
    updateBoard(game.Workspace.Leaderboard, data)
    wait(.1)
end

Answer this question