Hello, I was trying to make a Global Death Leaderboard but nothing is showing up on the Leaderboard and i don’t know why can anybody help me with my problem would be really nice since im trying to continue my game and thhis is the only thing i’ll have to do before i can publish it for everyon :slight_smile. I’ve also looked for some mistakes but didn’t find any so here is my code so you can see if there are any mistakes!
local DataStoreService = game:GetService("DataStoreService")
local DeathsLeaderboard = DataStoreService:GetOrderedDataStore("DeathsLeaderboard")
local function updateLeaderboard()
local success, errorMessage = pcall(function()
local Data = DeathsLeaderboard:GetSortedAsync(false, 5)
local DeathsPage = Data:GetCurrentPage()
for Rank, data in ipairs(DeathsPage) do
local userName = game.Players:GetNameFromUserIdAsync(tonumber(data.key))
local Name = userName
local Deaths = data.value
local isOnLB = false
for i, v in pairs(game.Workspace.Lobby.Leaderboards.Leaderboard_Deaths.DeathLeaderboard.SurfaceGui.Holder:GetChildren()) do
if v.Player.Text == Name then
isOnLB = true
break
end
end
if Deaths and isOnLB == false then
local newLBFrame = game.ReplicatedStorage:WaitForChild("LeaderboardFrameDeaths"):Clone()
newLBFrame.Player.Text = Name
newLBFrame.Deaths.Text = Deaths
newLBFrame.Rank.Text = "#"..Name
newLBFrame.Position = UDim2.new(0, 0, newLBFrame.Position.Y.Scale + (.1 * game.Workspace.Lobby.Leaderboards.Leaderboard_Deaths.DeathLeaderboard.SurfaceGui.Holder:GetChildren()), 0)
newLBFrame.Parent = game.Workspace.Lobby.Leaderboards.Leaderboard_Deaths.DeathLeaderboard.SurfaceGui.Holder
end
end
end)
if not success then
print(errorMessage)
end
end
while true do
for _, player in pairs(game.Players:GetPlayers()) do
DeathsLeaderboard:SetAsync(player.UserId, player.leaderstats.Deaths.Value)
end
for _, frame in pairs(game.Workspace.Lobby.Leaderboards.Leaderboard_Deaths.DeathLeaderboard.SurfaceGui.Holder:GetChildren()) do
frame:Destroy()
end
updateLeaderboard()
print("Updated!")
wait(10)
end
If you find any coding mistakes please fix them or help me fixing them by discribing where ive made a mistake and btw it also work its just not showing up on gui but the code goes trough the and and also print Updating! Thank you!