It uses a surface gui and clones a frame and then parents it to teh scrolling frame.
local DataStore = game:GetService("DataStoreService")
local ODS = DataStore:GetOrderedDataStore("MoneyStats")
local Players = game:GetService("Players")
local Scrolling = script.Parent.Leaders
local function cleanboard()
print("Clearing Board | function cleanbaord()")
local Descends = Scrolling:GetChildren()
for i, Descend in pairs(Descends) do
if Descend:IsA("Frame") then
Descend:Destroy()
end
end
end
function updateboard()
local pages = ODS:GetSortedAsync(false, 10)
local CurrentPage = pages:GetCurrentPage()
warn("Update Function Provoked | function updateboard()")
for i, v in ipairs(CurrentPage) do
print({v.key, v.value})
local userId = v.key
local score = v.value
local frame = script.Frame:Clone()
pcall(function()
frame.PName.Text = Players:GetNameFromUserIdAsync(userId)
end)
pcall(function ()
frame.PImage.Image = Players:GetUserThumbnailAsync(userId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
end)
frame.PAmount.Text = "$"..score
frame.PRank.Text = "#"..i
frame.Parent = Scrolling
warn(userId.." is ranked #"..i.." with "..score.."Cash")
end
end
while true do
local success, message = pcall(function()
cleanboard()
task.wait(1)
updateboard()
end)
if not success then
print(message)
end
task.wait(60)
end
it gets to “warn(“Update Function Provoked | function updateboard()”)” and stops
I tried and I originally had that, but I believe ipairs is better for loops, I think that is why I originally changed it, I believe I saw that in Documentation.
Its not empty, it loads in to the Leaderstat just fine.
I could understand if it wont work if there’s not enough Keys in the datastore, but I set it to 1 at some point and it still hasn’t come up.