I am trying to make a general leaderboard. In the script I have 3 parts, the first part creates 10 slots for players names and scores on the leaderboard. The second part is a function that is to organize a datastore in descending order, get information and fill the slots respectively while the third part runs the function continuously. The second and third parts didn't seem to work, so I debugged them. They were proven to work but I am not seeing results, I think it is a problem in the script but I am not getting any errors in the output. If you can find the error please help.
Script:
for i = 1,10 do
local Sam = script.Sample:Clone()
Sam.Name = i
Sam.Parent = script.Parent.SurfaceGui.ScrollingFrame
Sam.UserPos.Text = "[#"..tostring(i).."]"
Sam.UserScore.Text = "Nil"
Sam.UserName.Text = ""
Sam.LayoutOrder = i
script.Parent.SurfaceGui.ScrollingFrame.CanvasSize = UDim2.new(0,0,0,0.05*i)
end
function UpdateGui()
local datastoreservice = game:GetService("DataStoreService")
local datastore = datastoreservice:GetOrderedDataStore("StrengthStore")
local pages = datastore:GetSortedAsync(true,10)
local data = pages:GetCurrentPage()
for k,v in pairs(data) do
if tonumber(v.key) > 1 then
local frame = script.Parent.SurfaceGui.ScrollingFrame:FindFirstChild(tostring(k))
if frame then
frame.UserName.Text = game.Players:GetNameFromUserIdAsync(v.key)
frame.UserScore.Text = tostring(v.Value)
end
end
end
end
while true do
UpdateGui()
wait(2)
end
