So, I am trying to make a global leaderboard here.
I have written the script, but when I join it just shows nil.
It does not show my name or my friend’s name.
Can anyone help fix it?
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 = 1 -- This is your score.
local DataStore = game:GetService("DataStoreService"):GetOrderedDataStore("Aligator")
DataStore:SetAsync(v.UserId, Data)
end
local DataStore = game:GetService("DataStoreService"):GetOrderedDataStore("Aligator")
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)
end
end
end
end
while true do
UpdateGui()
wait(2)
end
it’s still the same thing, also this video should help on what I’m trying to achieve:
What I am trying to do is trying to make a global leaderboard from this tutorial, I checked a lot of times and is very sure that I am not missing anything, what’s the problem?