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

Why does my Leaderboard script leave random positions blank?

Asked by 3 years ago

My leaderboard works without errors, but blank names and values will appear in random positions. For example, my leaderboard displays the position number, player name, and number of wins the player scored. The leaderboard works as expected, except the 8th position which displays the placeholder(# PlayerName --) instead of the person who placed 8th and their number of wins. I wonder if the problem is in my leaderboard script or my datastore script? Here is my leaderboard script:

--                                  WINS LEADERBOARD
for i = 1, 16 do

    local Sam = script.Sample:Clone()

    Sam.Parent = script.Parent.SurfaceGui.Frame.ScrollingFrame

    Sam.Name = i

    Sam.Rank.Text = "#" .. tostring(i)

    --Sam.Username = "Player Name"

    Sam.LayoutOrder = i

end



function UpdateGui()

    local WinsLeaderboard = game:GetService("DataStoreService"):GetOrderedDataStore("TopWins")

    local data = WinsLeaderboard:GetSortedAsync(false,16)

    local page = data:GetCurrentPage()



    for i, v in ipairs(page) do

        --print(v.key)

        if tonumber(v.key) >= 1 then

            local Frame = script.Parent.SurfaceGui.Frame.ScrollingFrame:FindFirstChild(i-1)

            if Frame then

                Frame.Username.Text = game.Players:GetNameFromUserIdAsync(v.key)

                Frame.WinCount.Text = v.value

                --print(game.Players:GetNameFromUserIdAsync(v.key))

                --print(v.value)

            end

        end

        wait()

    end

end



while true do

    UpdateGui()

    wait(300)

    --players cannot see their position change on the leaderboards because their new

    --scores don't save until they leave

end
0
Could You Send A Image of What It Looks Like LoneSpace_Ranger 4 — 3y

Answer this question