So, I have a leaderboard here, but :GetCurrentPage() only returns two keys and values, but #:GetCurrentPage() returns 4. So there are multiple people on the datastore, but only two values. Can anyone help? Here is my script:
local function Handler()
local Success, Err = pcall(function()
local Page = game:GetService('DataStoreService'):GetOrderedDataStore('Donate'):GetSortedAsync(false, 50):GetCurrentPage()
for Rank, Data in ipairs(Page) do
print(#Page) --prints 4
if tonumber(Data.key) >1 then
print(Data.value)--only prints two times
local Name = game.Players:GetNameFromUserIdAsync(Data.key)
local UserId = Data.key
local Cash = Data.value
if tonumber(Data.value) >=5 then
local NewObj = game.ReplicatedStorage.Sample:Clone()
NewObj.User.Text = Name
NewObj.Amount.Text = game:GetService('DataStoreService'):GetDataStore('Donate'):GetAsync(UserId)
NewObj.Img.Image = game.Players:GetUserThumbnailAsync(UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size100x100)
NewObj.Parent = game.Workspace.DonationBoard.MainBoard.Main.SurfaceGui.ScrollingFrame
if Rank == 1 then
NewObj.BackgroundColor3 = Color3.fromRGB(223, 232, 56)
local topUser = game.Players:GetUserIdFromNameAsync(NewObj.User.Text)
workspace.TopDonator.Configuration.userId.Value = topUser
workspace.TopDonator.Head.Rank.RankText.Text = game:GetService('DataStoreService'):GetDataStore('RoleStore'):GetAsync(topUser)
workspace.TopDonator.Head.NameText.InformationLabel.Text = NewObj.User.Text
end
if Rank == 2 then
NewObj.BackgroundColor3 = Color3.fromRGB(142, 143, 130)
end
if Rank == 3 then
NewObj.BackgroundColor3 = Color3.fromRGB(189, 120, 62)
end
end
for i = 1, #game.Workspace.DonationBoard.MainBoard.Main.SurfaceGui.ScrollingFrame:GetChildren() do
local amount = i - 1
game.Workspace.DonationBoard.MainBoard.Main.SurfaceGui.ScrollingFrame.CanvasSize = UDim2.new(0,0,0,amount*100)
end
end
end
end)
if not Success then
error("Error: " .. Err)
end
end
while true do
for _, Frame in pairs(workspace.DonationBoard.MainBoard.Main.SurfaceGui.ScrollingFrame:GetChildren()) do
if Frame:IsA('Frame') then
Frame:Destroy()
end
end
Handler()
wait(10)
end