-
What do you want to achieve?
I want to fix my global leaderboard -
What is the issue?
The code doesn’t give any errors, but it doesn’t display the leaderboard -
What solutions have you tried so far?
I noticed that the clone didn’t go to the “Holder”, I tried messing with the code a bit, but I can’t figure it out
Here is the patch to the leaderboard:
Does anybody have any ideas on what’s wrong with the code?
(It’s 2 AM in my country, sorry if I don’t respond)
local DataStoreService = game:GetService("DataStoreService")
local WinsLeaderboard = DataStoreService:GetOrderedDataStore("WinsLeaderboard")
local function updateLeaderboard()
local success, errorMessage = pcall(function()
local Data = WinsLeaderboard:GetSortedAsync(false, 5)
local WinsPage = Data:GetCurrentPage()
for Rank, data in ipairs(WinsPage) do
local userName = game.Players:GetNameFromUserIdAsync(tonumber(data.key))
local Name = userName
local Wins = data.Value
local isOnLeaderboard = false
for i, v in pairs(game.Workspace.TimeLeaderboard.Part1.SurfaceGui.MainFrame.Display.Holder:GetChildren()) do
if v.Player.Text == Name then
isOnLeaderboard = true
break
end
end
if Wins and isOnLeaderboard == false then
local newLbFrame = game.ReplicatedStorage:WaitForChild("LeaderboardFrame"):Clone()
newLbFrame.Player.Text = Name
newLbFrame.Wins.Text = Wins
newLbFrame.Rank.Text = "#"..Rank
newLbFrame.Position = UDim2.new(0,0,newLbFrame.Position.Y.Scale + (.08 * #game.Workspace.TimeLeaderboard.Part1.SurfaceGui.MainFrame.Display.Holder:GetChildren()), 0)
newLbFrame.Parent = game.Workspace.TimeLeaderboard.Part1.SurfaceGui.MainFrame.Display.Holder
end
end
end)
if not success then
print(errorMessage)
end
end
while true do
for _, player in pairs(game.Players:GetPlayers()) do
WinsLeaderboard:SetAsync(player.UserId, player.leaderstats.Time.Value)
end
for _, frame in pairs(game.Workspace.TimeLeaderboard.Part1.SurfaceGui.MainFrame.Display.Holder:GetChildren()) do
frame:Destroy()
end
updateLeaderboard()
print("Updated")
wait(10)
end