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.