Issue with my custom roblox leaderboard system that replace the roblox defaut leaderboard

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    i want it where the frame well clone with the playername what place the player in and how much the player eat
  2. What is the issue? Include screenshots / videos if possible!
    I’m having issue with my leaderboard system where the frame not cloning with the player name what place the player in and how much the player eat but its not cloaining the frame i did added a print statment for the updateAllLeaderboards function in remote event to see if they both are fireing but thay are not fireing
  3. What solutions have you tried so far? Did you look for solutions on the Creator Hub?
    i tryed added check for each elements that in the frame for the gui using if statments

hers my client script

local Players = game:GetService("Players")
local player = Players.LocalPlayer
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local gui = player:WaitForChild("PlayerGui"):WaitForChild("LeaderboardGui") 
local holder = gui:WaitForChild("Holder")
local template = gui:WaitForChild("Template")




local updateEvent = ReplicatedStorage:WaitForChild("UpdateLeaderboard")



local function updateLeaderboard(data)
	print("function fired")
	for _, child in ipairs(holder:GetChildren()) do
		if child:IsA("Frame") and child.Name == "Entry" then
			child:Destroy()
		end
	end
	
	for rank, info in ipairs(data) do
		if rank <= 1 then
			local newEntry = template:Clone()
			newEntry.Name = "Entry"
			newEntry.Parent = holder
			newEntry.Visible = true
			
			local placeNumber = newEntry:WaitForChild("placeNumber")
			local playerName = newEntry:WaitForChild("playerName")
			local sizeNumber = newEntry:WaitForChild("SizeNumber")
			local playerImage = newEntry:WaitForChild("PlayerImage")

			
			
			if placeNumber then
				placeNumber.Text = tostring(rank)
			end
			
			if playerName then
				playerName.Text = info.DisplayName
			end
			
			if sizeNumber then
				sizeNumber.Text = tostring(info.EatCount)
			end
			
			if playerImage then
				local content, _ = Players:GetUserThumbnailAsync(info.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size100x100)
				playerImage.Image = content
			end
		end
	end
end

updateEvent.OnClientEvent:Connect(function(data)
	updateLeaderboard(data)
	print("event fired")
end)

hers my server script

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local updateEvent = ReplicatedStorage:WaitForChild("UpdateLeaderboard")

local function updateAllLeaderboards()
	print("function fired")
	local data = {}
	
	for _, plr in ipairs(Players:GetPlayers()) do
		local eatCount = plr.Character and plr.Character:FindFirstChild("EatCount")
		if eatCount then
			table.insert(data, {
				UserId = plr.UserId,
				DisplayName = plr.DisplayName,
				EatCount = eatCount.Value
			})
		end
	end
	
	table.sort(data, function(a, b)
		return a.EatCount > b.EatCount
	end)
	
	updateEvent:FireAllClients(data)
	print("Firing leaderboard update with", #data, "entries")

end

Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		char:WaitForChild("Humanoid")
		local eatCoin = char:WaitForChild("EatCount", 5)
		if eatCoin then
			eatCoin.Changed:Connect(updateAllLeaderboards)
			updateAllLeaderboards()
		end
	end)
end)

Players.PlayerRemoving:Connect(function()
	updateAllLeaderboards()
end)

Just a hunch for now, I don’t believe the issue is coming from the actual functions for updating but actually earlier than that. I’m unsure how much testing you’ve gotten done so far or where you have done the testing but my current prediction is the Character may already have been loaded so it never hits that CharacterAdded Event, this is much more unlikely for the PlayerAdded.

But inside the PlayerAdded try the code below, it’s not a guarantee it’d work but worth a shot I suppose.

local function updateChar(char)
	print("Updating Character")
	char:WaitForChild("Humanoid")
	print("Humanoid Found")
	local eatCoin = char:WaitForChild("EatCount", 5)
	if eatCoin then
		print("Eat Coin Found")
		eatCoin.Changed:Connect(updateAllLeaderboards)
		updateAllLeaderboards()
	end
end

Players.PlayerAdded:Connect(function(plr)
	if plr.Character then
		updateChar(plr.Character)
	end
	
	plr.CharacterAdded:Connect(updateChar)
end)

Listen to the guy on top, but I would want to say that you probably don’t need server-client communication for a leaderboard system.

This is just some recommended stuff, i’m not fixing anything here (as I believe the person on top of me already did)

You can loop through the current players in the server from the client and handle everything else. It can be exploited by “faking a coin count” but, the exploiting doesn’t do anything else other than faking the number. If you want to avoid that you could send an update from the server every 20-40 seconds, but it’s not harmful.

I am saying this because firing a remote to all clients every time someone eats something might be unoptimized.

Of course I haven’t tested it or anything, but my own player list was coded on client (it doesn’t have any statistics tho)

You should also remove the :WaitForChild’s and checks on the client. If you’re cloning a template then it’s 100% guaranteed to have the same UIs. You can also wrap the GetUserThumbnailAsync call to a pcall to not error your script if it fails.