local DataStoreService = game:GetService("DataStoreService")
local levelLeaderboard = DataStoreService:GetOrderedDataStore("LevelLeaderboard")
local PositionUIBoard = game.Workspace.GlobalLeaderBoard.leaderBoardGUI.Holder
local function updateLeaderboard ()
local success, errorMessage = pcall(function()
local Data = levelLeaderboard:GetSortedAsync(false, 5)
local levelPage = Data:GetCurrentPage()
for RANK, data in ipairs(levelPage) do
local userName = game.Players:GetNameFromUserIdAsync(tonumber(data.key))
local Name = userName
local level = data.value
local isOnLeaderboard = false
while true do
for _, player in pairs(game.Players:GetPlayers()) do
levelLeaderboard:SetAsync(player.UserId, player.leaderstats1.level.Value)
end
What solutions have you tried so far? I looked it was connected with the data, but this is what was needed
local DataStoreService = game:GetService("DataStoreService")
local levelLeaderboard = DataStoreService:GetOrderedDataStore("LevelLeaderboard")
local PositionUIBoard = game.Workspace.GlobalLeaderBoard.leaderBoardGUI.Holder
local function updateLeaderboard ()
local success, errorMessage = pcall(function()
local Data = levelLeaderboard:GetSortedAsync(false, 5)
local levelPage = Data:GetCurrentPage()
for RANK, data in ipairs(levelPage) do
local userName = game.Players:GetNameFromUserIdAsync(tonumber(data.key))
local Name = userName
local level = data.value
local isOnLeaderboard = false
for i, v in pairs(PositionUIBoard:GetChildren() ) do
if v.Player.Text == Name then
isOnLeaderboard = true
break
end
end
if level and isOnLeaderboard == false then
local newLBFrame = game.ReplicatedStorage:WaitForChild("LeaderboardFrame"):Clone()
newLBFrame.Player.Text = Name
newLBFrame.level.Text = level
newLBFrame.RANK.Text = "#"..RANK
newLBFrame.Position = UDim2.new(0,0, newLBFrame.Position.Y.Scale + (.08 * #PositionUIBoard:GetChildren()), 0)
newLBFrame.Position = PositionUIBoard
end
end
end)
if not success then
print(errorMessage)
end
end
while true do
for _, player in pairs(game.Players:GetPlayers()) do
levelLeaderboard:SetAsync(player.UserId, player.leaderstats1.level.Value)
end
for _, frame in pairs(PositionUIBoard:GetChildren()) do
frame:Destroy()
end
updateLeaderboard()
print ("Update!")
wait(10)
end