[SOLVED] Global Leaderboard

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

You have put v.Value with a capital V. From the code sample on the Developer Hub, it appears that this should be a lowercase v: v.value.

In your for loop after getting the DataStorePage, try this:

		if Frame then
			Frame.Username.Text = game.Players.GetNameFromUserIdAsync(v.key)
			Frame.Score.Text = tostring(v.value) -- lowercase v
		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?

If it helps, there’s a tutorial inside of the DevForum on global leaderboards.

Oh shoot, just noticed some wrong capitalism, fixed them and now it works.
Apologies for not over-checking before making this post.

Aplogies, but I already fixed it. Thank you for trying to help.

1 Like