Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Pushes the limit of the ordered datastore from 100, to infinite
- local DataStoreService = game:GetService("DataStoreService")
- local scrollingFrame = workspace.Part.SurfaceGui.ScrollingFrame
- local HttpService = game:GetService("HttpService")
- local DataStore = DataStoreService:GetOrderedDataStore("OrderedDataStore1")
- local tableSize = 100
- local overallRank = 0
- local pages = DataStore:GetSortedAsync(false, tableSize)
- scrollingFrame.DescendantAdded:Connect(function()
- local childrenCount = -1
- for i,v in scrollingFrame:GetChildren() do
- childrenCount += 1
- end
- local devidedNumber = math.ceil(childrenCount / 10)
- scrollingFrame.CanvasSize = UDim2.new(0,0,devidedNumber,0)
- end)
- -- Update leaderboard
- while true do
- print("Refreshed")
- -- Get the datastore data
- local entries = pages:GetCurrentPage()
- local indexTable = {}
- -- Get the sorted data from the current page and display it
- for rank, entry in ipairs(entries) do
- overallRank += 1
- local template = game.ReplicatedStorage.Template:Clone()
- template.Parent = scrollingFrame
- template.Statistic.Text = tostring(entry.value)
- template.Username.Text = entry.key
- template.Rank.Text = tostring(overallRank)
- local index = math.floor((overallRank - 1) / tableSize)
- indexTable[entry.key] = {playerRank = overallRank, index = index}
- end
- -- Check if all pages are finished processing
- if pages.IsFinished then
- task.wait(5)
- overallRank = 0
- pages = DataStore:GetSortedAsync(false,tableSize)
- for i,guiObject in scrollingFrame:GetChildren() do
- wait(0.1)
- if not guiObject:IsA("UIListLayout") then
- guiObject:Remove()
- end
- end
- else
- pages:AdvanceToNextPageAsync()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment