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

ordered datastore global leaderboard, what is wrong?

Asked by 7 years ago

Hello,I'm making a game on roblox, but a script doesn't work... Its a global leaderboard with most wins on it... But it stays black... and I gave some account some wins and did not came on it... what is the problem in the script?

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

function updateBoard(board, data)
    for k,v in pairs(data) do
        local pos = k
        local name = v.key
        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.Leaderboards.Leaderboard, data)
        end
    end)

    if not success then
        print(message)
    end

    wait(60)
end

Its the only script in it and the surface gui is already on the board to... Help! I hope you can help me! ... thanks

-Gamer_io

Answer this question