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

ODS Leaderboard, What's wrong with my script? [NOT SOLVED]

Asked by
sgsharp 265 Moderation Voter
10 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

Okay, so I am making a game, and it has a GUI Ordered Leaderboard that uses ODS (Ordered DataStores). I previously had the leaderboard working on a SurfaceGui, but I wanted to turn it into a ScreenGui... So I did. And when I did, it basically stopped updating. Please tell me what I have done wrong, how I could possibly fix it, and if there's a possible way to improve it.

Wiki links & in-depth examples would be greatly appreciated for future reference with Data & DataStores.

This code is written in a regular Script...

local Data = game:GetService("DataStoreService"):GetOrderedDataStore("ScoreBoard")


game.Players.PlayerAdded:connect(function(Player)

    wait(3)

    while true do
        wait(5) 

        Data:SetAsync(Player.Name, Player.Apples.Value)

    end
end)

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.Apples:FindFirstChild("Name" .. pos)
        nametextbox.Text = name
        local scoretextbox = board.Apples:FindFirstChild("Name" .. pos).Score
        scoretextbox.Text = score
    end 
end

while true do
    local pages = Data:GetSortedAsync(false, 10)
    local data = pages:GetCurrentPage()
    updateBoard(script.Parent, data)
    if not pages.IsFinished then
        pages:AdvanceToNextPageAsync()
        data = pages:GetCurrentPage()
        updateBoard(script.Parent.Next10, data)
    end
    wait(.1)
end

Please answer as soon as possible. I have plenty of players asking me to fix the leaderboard.

1 answer

Log in to vote
-2
Answered by
Subbix -5
10 years ago

Do you have the output?

0
Yes, there's no error in the output or developer console. I'm not sure what the problem is... sgsharp 265 — 10y
0
That's odd. Im a bigginer scripter buts its odd how i cant find the problem. Have you tried local script? Subbix -5 — 10y
Ad

Answer this question