-
What do you want to achieve? i want to fix my leaderboard script
-
What is the issue? it isnt working, there are no errors and it’s saying that “it got updated”
-
What solutions have you tried so far? look twice through the script
!
local StudsLeaderboard = DataStoreService:GetOrderedDataStore("StudsLeaderboard")
local function updateLeaderboard()
local success, errorMessage = pcall(function()
local Data = StudsLeaderboard:GetSortedAsync(false, 5)
local StudsPage = Data:GetCurrentPage ()
for Rank, data in ipairs(StudsPage) do
local userName = game.Players:GetNameFromUserIDAsync(tonumber(data.key))
local Name = userName
local Studs = data.value
local isOnLeaderboard = false
for i, v in pairs(game.Workspace.GlobalLeaderboard.LeaderboardGUI.Holder:GetChildren()) do
if v.Player.Text == Name then
isOnLeaderboard = true
break
end
end
if Studs and isOnLeaderboard == false then
local newLBFrame = game.ReplicatedStorage:WaitForChild("LeaderboardFrame"):Clone()
newLBFrame.Player.Text = Name
newLBFrame.Studs.Text = Studs
newLBFrame.Rank.Text = "#"..Rank
newLBFrame.Position = UDim2.new(0, 0, newLBFrame.Position.Y.Scale + (.08 * #game.Workspace.GlobalLeaderboard.LeaderboardGUI.Holder:GetChildren()), 0)
newLBFrame.Parent = game.Workspace.GlobalLeaderboard.LeaderboardGUI.Holder
end
end
end)
if not success then
print(errorMessage)
end
end
while true do
for _, player in pairs(game.Players:GetPlayers()) do
StudsLeaderboard:GetAsync(player.UserId, player.leaderstats.Studs.Value)
end
for _, frame in pairs(game.Workspace.GlobalLeaderboard.LeaderboardGUI.Holder:GetChildren())do
frame:Destroy()
end
updateLeaderboard()
print("Updated!")
wait(50)
end```