My Global Death Leaderboard not showing anything!

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! :smiley:

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!

Hello, hmm can you confirm if the newLBFrame are being added to game.Workspace.Lobby.Leaderboards.Leaderboard_Deaths.DeathLeaderboard.SurfaceGui.Holder, like could you playtest and see if they appear there

no they sadly dont appear (sorry for late answer)

Hmm could you do some debuging try to print(Deaths, isOnLB) before the line
if Deaths and isOnLB == false then

try to see id deaths is nil or if isonlb is true

Ye sure lemme quickly do it and imma give you everything what it says in output

Update:

you tried multiplying .1 with children

.1*game.Workspace.Lobby.Leaderboards.Leaderboard_Deaths.DeathLeaderboard.SurfaceGui.Holder:GetChildren()

is that the only thing why it didnt work??

I’m unsure if that’s the only issue, but I believe it was the line of script that was causing the error in your console

so i found a solution and its just me not noticing a little mistake in the error but still thanks to all who helped!

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.