I’m trying to make a leaderboard for my game to see who the top three people are with the most of the currency, but i have a problem. Once it gets to a certain part in my script it just stops. It stops after it prints “Page”. I don’t know why this is happening or how to fix it. Although i did try lowering the number where it says “GetSortedAsync(false,3)” but yeah. Any help?
wait()
for i = 1,3 do
local clone = script.Parent.Player1:Clone()
clone.Name = "Player"..i
clone.Text = clone.Name
print(i)
end
function Update()
local ds = game:GetService("DataStoreService"):GetOrderedDataStore("Toonies")
print("Got datastore")
local pages = ds:GetSortedAsync(false,3)
print("Sorted")
local data = pages:GetCurrentPage()
print("Page")
for i,v in pairs(data) do
print("Looping!")
if tonumber(v.key) >= 1 then
print("Key equals or is greater than 1!")
local frame = script.Parent:FindFirstChild("Player"..i)
if frame then
print("Frame!")
local player = game.Players:GetPlayerByUserId(v.key)
frame.Text = player.Name..": "..player.leaderstats.Toonies.Value
print("Changed!")
end
end
end
end
Update()
while wait(2) do
Update()
end