Hello.
I am experiencing a weird bug where a global leaderboard doesn’t display users and the value correctly:
(there are usernames next to numbers)
There are some empty spaces even though there shouldn’t be. And some players that should be on the leaderboard are missing.
It worked fine but now it’s kinda broken.
I noticed that when I was changing some values with an admin system even though I put tonumber() around args - value. (Data is saved in datastore2 and then also in ordered datastore).
What could cause that?
Thank you!
P.S.: leaderborad script:
local DataStore = game:GetService("DataStoreService"):GetOrderedDataStore("TimeOrderedDS")
for i = 1,10 do
local Sam = script.Sample:Clone()
Sam.Name = i
Sam.Parent = script.Parent.Parent.SurfaceGui.Frame.Leaderboard.ScrollingFrame
Sam.UserPos.Text = tostring(i)
Sam.score.Text = ""
Sam.UserName.Text = ""
Sam.LayoutOrder = i
--script.Parent.Parent.SurfaceGui.Frame.Leaderboard.ScrollingFrame.CanvasSize = UDim2.new(0,0,0,50*i)
end
local function UpdateGui()
pcall(function()
local Pages = DataStore:GetSortedAsync(false, 10)
local Data = Pages:GetCurrentPage()
for k,v in pairs(Data) do
if tonumber(v.key) >= 1 then
local Frame = script.Parent.Parent.SurfaceGui.Frame.Leaderboard.ScrollingFrame:FindFirstChild(tostring(k))
if Frame then
Frame.UserName.Text = game.Players:GetNameFromUserIdAsync(v.key)
Frame.score.Text = tostring(v.value)
print("yes")
end
end
end
end)
end
while true do
UpdateGui()
wait(60)
end```