You can write your topic however you want, but you need to answer these questions:
- 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 - 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 - 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)