Hello, I’m OriginalDevelops! I’m trying to make a Global Leaderboard script, but it didnt work . I’ve trying to fix it but it didn’t, I couldn’t fix it… So I want you to help me to see what is the issue of my script below and help me fix it ! My Script ( Server Script ) ::
local DataStoreService = game:GetService("DataStoreService")
local StrengthLeaderboards = DataStoreService:GetOrderedDataStore("StrengthLeaderboards")
local function updateLeaderboards()
local success, errormessage = pcall(function()
local Data = StrengthLeaderboards:GetSortedAsync(false, 5)
local strengthPage = Data:GetCurrentPage()
for Rank, data in ipairs(strengthPage) do
local userName = game.Players:GetNameFromUserIdAsync(tonumber(data.key))
local Name = userName
local strength = data.Value
local isOnLeaderboard = false
for i, v in pairs(game.Workspace.Lobby.StrengthLeaderboard.Leaderboard.Holder:GetChildren()) do
if v.Player.Text == Name then
isOnLeaderboard = true
break
end
end
if strength and isOnLeaderboard == false then
local newLbFrame = game.ReplicatedStorage:WaitForChild("LeaderboardFrame"):Clone()
newLbFrame.Name.Text = Name
newLbFrame.Total.Text = strength
newLbFrame.Rank.Text = "#"..Rank
newLbFrame.Position = UDim2.new(0, 0, newLbFrame.Position.Y.Scale + (0.8 * #game.Workspace.Lobby.StrengthLeaderboard.Leaderboard.Holder:GetChildren()), 0)
newLbFrame.Parent = game.Workspace.Lobby.StrengthLeaderboard.Leaderboard.Holder
end
end
end)
if not success then
print(errormessage)
end
end
while wait(30) do
for _, player in pairs(game.Players:GetPlayers()) do
StrengthLeaderboards:GetAsync(player.UserId, player.Stats.Strength.Value)
end
for _, frame in pairs(game.Workspace.Lobby.StrengthLeaderboard.Leaderboard.Holder:GetChildren()) do
frame:Destroy()
end
updateLeaderboards()
print("Updated!")
end