Why is the leadboard not working?

I have 5 leaderboards in my game, I added speedrun in my game as its a obby game but turns out speed run leaderboards don’t work but other leaderboards work.

This is how it looks:
image

Here is the script:

local datastore = game:GetService("DataStoreService")
local data1 = datastore:GetOrderedDataStore("Dif1SaveService")

local function updateleaderboard()
    local success, errormessage = pcall(function()
        local data = data1:GetSortedAsync(false,25)
        local currentpage = data:GetCurrentPage()
        for i,v in ipairs(currentpage) do
            local plr = game.Players:GetNameFromUserIdAsync(tonumber(v.key))
            local name = plr
            local wins = v.value/1000
            local useridofplayer = v.key
            local rank = i
            local onleaderboard = false
            for i,v in pairs(game.Workspace.leaderboard3.SurfaceGui.ScrollingFrame:GetChildren()) do
                if v.PlayerName.Text == name then
                    onleaderboard = true
                    break
                end
            end
            if wins and onleaderboard == false then
                local frameclone = game.ReplicatedStorage.LeaderboardFrame:Clone()
                frameclone.PlayerName.Text = name
                frameclone.RankLabel.Text = "#"..rank
                frameclone.WinsLabel.Text = wins
                frameclone.PlayerImageLabel.Image = game.Players:GetUserThumbnailAsync(useridofplayer,Enum.ThumbnailType.HeadShot,Enum.ThumbnailSize.Size150x150)
                frameclone.Position = UDim2.new(0,0,frameclone.Position.Y.Scale + (.04 * #game.Workspace.leaderboard3.SurfaceGui.ScrollingFrame:GetChildren()),0)
                frameclone.Parent = game.Workspace.leaderboard3.SurfaceGui.ScrollingFrame
            end
        end
    end)
    if not success then
        print(errormessage)
        game.Workspace.leaderboard4:Destroy()
    end
end

while true do
    for i,v in pairs(game.Players:GetPlayers()) do
        if tonumber(v.SpeedRun.Dif1.Value) >= 25 then
            local tosave = math.floor(v.SpeedRun.Dif1.Value*1000)
            data1:SetAsync(v.UserId, tosave)
        end
    end
    for i,v in pairs(game.Workspace.leaderboard4.SurfaceGui.ScrollingFrame:GetChildren()) do
        v:Destroy()
    end
    updateleaderboard()
    print("updated")
    wait(75)

I even waited 75 seconds so it refresh but nothing happen and there is no error.

Uh is it a roblox studio error or script error?

does anyone know how to fix this?

Try playing it in Roblox Client, not studio. Sometimes it might not work when testing in studio

I think you are missing a ‘end’ at the end of your script. Check the output windows for any errors.

2 Likes

I tested in public and vip server to.In studio while testing it to, but none worked and no error is printed.

Are you stating that only one leaderboard works out of others? If so, your script is utilising only one.

1 Like

All the other leaderboards work.

image

You see the leaderboard script 1,2,3,4,5

1,2 and 3 works but 4 and 5 which I made new did not work

It may not work because you’re budgeting a lot of :GetAsync()'s for one-time. Update each of the leaderboards at different periods, and it should be good.

By the way, I don’t advise to duplicate scripts. Instead, create new variables (since that’s the only difference), then loop for update.

1 Like

Oh I changed the cooldown to 30,45,75,90,150.

lemme test it

image

Others work very fine, even after changing cooldown but the new leaderboards don’t work

image

Are the scripts any different? Do they have data? Do they run when 1, 2, and 3 aren’t running?

1 Like

all are same but just the :GetDataStore() string changes for all, like 1 = “StageSave” 2 = “DonatedRobuxSave”. I can post the scripts if you want to

1 Like

do you know how to fix it? or its just a bug

Check if they consist of data, and actually run.

1 Like

they don’t actually are running i fixed them thank you for your time