Global Leaderboard not Updating and Showing

  1. Achieving a Level-System Game.

  2. I got problems with my Global Leaderboard it should look like this:
    image
    The TopBar is always there but the Template beneath is not.
    The Template is broken into 3 Text labels (from left to right) Rank, Name and Level and inside a Frame put in ReplicatedStorage.

The way it should go is through the Workspace onto the Part into the Holder.

Here is my script:

local DataStoreService = game:GetService("DataStoreService")
local LevelLeaderboard = DataStoreService:GetOrderedDataStore("LevelLeaderboard")

local function updateLeaderboard()
	local success, errorMessage = pcall(function()
		local Data = LevelLeaderboard:GetSortedAsync(false, 5)
		local LevelPage = Data:GetCurrentPage()
		for Rank, data in ipairs(LevelPage) do
			local userName = game.Players:GetNameFromUserIdAsync(tonumber(data.key))
			local Name = userName
			local Level = data.Value
			local isOnLeaderboard = false
			for i, v in pairs(game.Workspace.TVLevelLeaderboard.TVFace.LeaderboardGUI.Holder:GetChildren()) do
				if v.Player.Text == Name then
					isOnLeaderboard = true
					break
				end
			end
			
			if Level and isOnLeaderboard == false then
				local newLbFrame = game.ReplicatedStorage:WaitForChild("LeaderboardFrame"):Clone()
				newLbFrame.PName.Text = Name
				newLbFrame.PLevel.Text = Level
				newLbFrame.PRank.Text = "#"..Rank
				newLbFrame.Position = UDim2.new(0, 0, newLbFrame.Position.Y.Scale + (.08 * #game.Workspace.TVLevelLeaderboard.TVFace.LeaderboardGUI.Holder:GetChildren()), 0)
				newLbFrame.Parent = game.Workspace.TVLevelLeaderboard.TVFace.LeaderboardGUI.Holder
			end
		end
	end)
	
	if not success then
		print(errorMessage)
	end
end

while true do
	
	for _, Player in pairs(game.Players:GetPlayers()) do
		LevelLeaderboard:SetAsync(Player.UserId, Player.leaderstats.Level.Value)
	end
	
	for _, frame in pairs(game.Workspace.TVLevelLeaderboard.TVFace.LeaderboardGUI.Holder:GetChildren()) do
		frame:Destroy()
	end
	
	updateLeaderboard()
	print("Updated!")
	
	wait(10) --Will be set to 300
end

Tried changing the code for 2h hoping something else would happen. (I got no errorMessages through searching which means that I made no mistakes)

Prepared other Global Leaderboard methods but this one is still the best!
I was a lot online searching.

Nevermind got the problem myself solved! :upside_down_face: :sweat_smile:

1 Like

What did you do to fix it? I’m using a similar method and I also have problems with it.

I have to write a new one because this didn’t get through with my other codes so I deleted the Template.

I made/placed a new part 1 pixel away from the leaderboard and had to write a script that creates the leaderboard frame and leaderstats it’s working now way better than this old one.

If you want to have it I can send you a download link where you can get the same output as mine.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.