Global leaderboard

Hi, i try to show the player level in my server but it’s not work :confused: the playername and the order is correct but not the level:

Sans titre

My script is:

for i = 1,100 do
	local Sam = script.Sample:Clone()
	Sam.Name = i
	Sam.Parent = script.Parent.Levels.Frame.ScrollingFrame
	Sam.UserPos.Text = "[".. tostring(i) .."]"
	Sam.Level.Text = "Nil"
	Sam.UserName.Text = ""
	Sam.LayoutOrder = i
	script.Parent.Levels.Frame.ScrollingFrame.CanvasSize = UDim2.new(0,0,5,0*i)
end

function UpdateGui()
	for i,v in pairs(game.Players:GetChildren()) do
		local data = 1
		local datastore = game:GetService("DataStoreService"):GetOrderedDataStore("LevelSaveSystem")
		datastore:SetAsync(v.UserId,data)
	end
	local datastore = game:GetService("DataStoreService"):GetOrderedDataStore("LevelSaveSystem")
	local Pages = datastore:GetSortedAsync(false,100)
	local data = Pages:GetCurrentPage()
	for k,v in pairs(data) do
		if tonumber(v.key) >= 1 then
			local Frame = script.Parent.Levels.Frame.ScrollingFrame:FindFirstChild(tostring(k))
			if Frame then
				Frame.UserName.Text = game.Players:GetNameFromUserIdAsync(v.key)
				Frame.Level.Text = tostring(v.Value)
			end
		end
	end
end

while true do
	UpdateGui()
	wait(60)
end
1 Like

I’m pretty sure it’s v.value not v.Value

Now it’s not nil but 1, but my level is 2 so i don’t understant why it’s 1… :confused:

From what I can see you’re only setting it to 1?

i don’t know what i can write for get the level of players ^^

i have try: local data = player.leaderboard.level but it’s not work

You forgot to add .Value after level, it should look like that:

local data = player.leaderboard.level.Value

But i got this error: unknow player ^^

Sorry im not a pro in script :confused:

You didn’t define player, replace Player with v

1 Like

I have try v.status.Level.Value and v.status.Level but the number is 1 :confused: it’s not my level it’s strange

Did you wait for the leaderboard to update and data to save?

Oh it’s working x) thank you very much guy, i just have another question, you know why i can’t scroll under 35 ?

Sans titre

You probably have to change CanvasSize of the scrolling frame

3 Likes

I have try to modify but it’s same ^^ thanks for your help