Global Leaderboards Are Acting Up *HELP!*

Hey guys, I have two global leaderboards in my game. One works, but the other doesn’t. They have the exact same scripts except the names are edited as they should be. There are no errors there. One is for coins, one is for wins. From the leaderboard script that doesn’t work, there is one error- Players:GetNameFromUserId() failed because HTTP 404 (NotFound)
Here is the script-

local DataStoreService2 = game:GetService("DataStoreService")
local CoinsLeaderboard = DataStoreService2:GetOrderedDataStore("CoinsLeaderboard")

local function updateLeaderboard()
        local success, errorMessage = pcall (function()
                local Data = CoinsLeaderboard:GetSortedAsync(false, 10)
                local CoinsPage = Data:GetCurrentPage()
                for Rank, data in ipairs(CoinsPage) do
                       local userName = game.Players:GetNameFromUserIdAsync(tonumber(data.key))
                       local Name = userName
                       local Coins = data.value
                       local isOnLeaderboard = false
                       for i, v in pairs(game.Workspace.Lobby.Leaderboard.GlobalLeaderboard2.LeaderboardGUI2.Holder:GetChildren()) do
                             if v.Player.Text == Name then
                                  isOnLeaderboard = true
                                  break
                           end
                    end

                     if Coins and isOnLeaderboard == false then
                            local newLbFrame = game.ReplicatedStorage:WaitForChild("LeaderboardFrame2"):Clone()
                            newLbFrame.Player.Text = Name
                            newLbFrame.Coins.Text = Coins 
                            newLbFrame.Rank.Text = "#"..Rank
                            newLbFrame.Position = UDim2.new(0, 0, newLbFrame.Position.Y.Scale + (.08 * #game.Workspace.Lobby.Leaderboard.GlobalLeaderboard2.LeaderboardGUI2.Holder:GetChildren()), 0)
                            newLbFrame.Parent = game.Workspace.Lobby.Leaderboard.GlobalLeaderboard.LeaderboardGUI.Holder
                     end
              end
      end)

      if not success then
            print(errorMessage)
      end
end

while true do

        for _, player in pairs(game.Players:GetPlayers()) do
              CoinsLeaderboard:SetAsync(player.UserId, player.leaderstats.Coins.Value)
        end

        for _, frame in pairs (game.Workspace.Lobby.Leaderboard.GlobalLeaderboard2.LeaderboardGUI2.Holder:GetChildren()) do
              frame:Destroy()
        end

        updateLeaderboard()
        print("Updated!")

        wait(10)
end

Help is appreciated. Thanks.

2 Likes

Still looking for some answers with this one! Help is very appreciated!

1 Like

Does it say “GetNameFromUserId()” or “GetNameFromUserIdAsync()” in the error?

1 Like

GetNameFromUserId is the one in the error

1 Like

Does it say the line the error is on?

This line, the one that says that

Can you show the whole entire error, or is that the full error?

2 Likes

hmm, interesting, I think it’s this line.

local userName = game.Players:GetNameFromUserIdAsync(tonumber(data.key))

Does this happen continously?

2 Likes

As I can see, It happens every 10 seconds which is WAY to often.

1 Like

This is the entire error
Players:GetNameFromUserId() failed because HTTP 404 (NotFound)

What do you mean, by happen continuously?

I recommend you change the wait() duration to 60 or more in the while loop since 10 seconds is too fast to update.

2 Likes

Does it happen each time you’ve tested your game. If not, it’s most likely to be a web call failure. It should logically work if you try it again.

And yes as @BuilderDolphin said I would consider not updating every 10 secs.

2 Likes

Yes, I tested it about three times, and without fail it happened each time.

1 Like

Is the game published? If not, I think it has to to work.

1 Like

Yes, its published. It’s published alright.

Can you click the source, and see what line it highlights from output?

1 Like

But the output is a print() since it is a pcall function.

2 Likes

Maybe turn on HttpRequests and the API.

3 Likes

Line 32, the one with the print(error message)