so i followed a tutorial from BrawlDev which is good, a learn thing or two but the problem is that he ended the tutorial without finishing it and i have no idea how to update the leaderboard
here`s the code:
local DataStoreService = game:GetService('DataStoreService')
local myData = DataStoreService:GetOrderedDataStore('MyDataRebirths')
local item = script:WaitForChild("Item")
local playerContainer = script.Parent.screen.SurfaceGui.Container.PlayerContainer
game.Players.PlayerAdded:Connect(function(plr)
task.wait()
local rebirths = plr.leaderstats.Rebirths
while true do
task.wait(10)
local success, errorMsg = pcall(function()
myData:SetAsync(plr.UserId, rebirths.Value)
end)
if not success then
print(errorMsg)
end
end
end)
while true do
task.wait(10)
local success, pages = pcall(function()
return myData:GetSortedAsync(false, 10)
end)
if success then
local entries = pages:GetCurrentPage()
for rank, entry in pairs(entries) do
local clonedItem = item:Clone()
local username = game.Players:GetNameFromUserIdAsync(entry.key)
if username then
clonedItem.Name = username
clonedItem.NameText.Text = username
end
clonedItem.CashText.Text = entry.value
clonedItem.RankText.Text = rank
clonedItem.Parent = playerContainer
end
end
end
and it looks like that

it just repeats and i dont know how to make it refresh please help