As you read in the title, I'm trying to make a global leaderboard. It works, but it doesn't consistently work. What I mean is, if I have 0 credits, then it'll show 0 credits. After 30 seconds, if I have a different value than 0, then it should update on the leaderboard. However, it doesn't seem to update the leaderboard. Also, there's no errors in the output occurring. Help?
--SCRIPT-- local lb = game:GetService("DataStoreService"):GetOrderedDataStore("candyjumperstats") function addcommas(num) return tostring(math.floor(num)):reverse():gsub("(%d%d%d)","%1,"):gsub(",(%-7)$","%1"):reverse() end function update() for _,plr in next, game:GetService("Players"):GetPlayers() do pcall(function() lb:UpdateAsync(plr.UserId, function() return plr:WaitForChild("HighScore").Value end) end) end local data = lb:GetSortedAsync(false,10) local page = data:GetCurrentPage() for rank,info in next, page do pcall(function() local player = game:GetService("Players"):GetNameFromUserIdAsync(info.key) local frame = script.Parent.Frame.ScrollingFrame:FindFirstChild(rank) frame.User.Text = player frame.Rank.Text = "#"..rank frame.Amount.Text = addcommas(info.value) frame.Visible = true end end while wait(5) do update() end