Hello, I have here a global leaderboard and on the script here:
Frame.Score.Text = tostring(v.Value)
print(tostring(v.Value))
It prints nil, but should be printing 1. Here's the full script:
for i = 1, 10 do
local Sam = script.Sample:Clone()
Sam.Name = i
Sam.Parent = script.Parent.Frame.ScrollingFrame
Sam.UserPos.Text = "[" .. tostring(i) .. "]"
Sam.Score.Text = "Nil"
Sam.Username.Text = ""
Sam.LayoutOrder = i
script.Parent.Frame.ScrollingFrame.CanvasSize = UDim2.new(0, 0, 0, 50 * i)
end
function UpdateGui()
for i, v in pairs(game.Players:GetChildren()) do
local Data = tonumber(v.leaderstats.Prestige.Value)
local DataStore = game:GetService("DataStoreService"):GetOrderedDataStore("PrestigeD")
DataStore:SetAsync(v.UserId, Data)
end
local DataStore = game:GetService("DataStoreService"):GetOrderedDataStore("PrestigeD")
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.Frame.ScrollingFrame:FindFirstChild(tostring(k))
if Frame then
Frame.Username.Text = game.Players:GetNameFromUserIdAsync(v.key)
Frame.Score.Text = tostring(v.Value)
print(tostring(v.Value))
end
end
end
end
while true do
UpdateGui()
wait(60)
end
I don't know why this happens, and yes that is the name of my datastore. If someone could tell me whats going on, that would be so helpful!
