My Global Leaderboard is conflicting with another Global Leaderboard

Hey everyone! What I want to accomplish is to make it where I can have multiple leaderboards in my game without them conflicting with each other. My first leaderboard is based on the cash of other players (Balance Leaderboard) while the other leaderboard is based on player robux donations to the game (Donation Leaderboard).

To describe my issue in an advanced nature, the Balance leaderboard keeps on preventing the Donation Leaderboard from displaying my Top 10 Donators fully (or even at all) onto its SurfaceGui. In addition to this, after my Balance leaderboard loads in the top players, the Donation Leaderboard stops giving me the “remaining time” until it refreshes. Here is a video on what I mean.
robloxapp-20200807-2247080.wmv (661.7 KB)

I tried making separate data stores for each global leaderboard and made sure that my leaderboards don’t have parts that share the same name but it doesn’t seem to fix anything.

Leaderstats:

game.Players.PlayerAdded:connect(function(p)
	local stats = Instance.new("IntValue")
	stats.Name = "leaderstats"
	stats.Parent = p
	
	local money = Instance.new("IntValue")
	money.Name = "Balance" -- Change "Money" to anything you want to name it like "Cash"
	money.Value = 0 -- Change the value to how many you want when the player joins the game
	money.Parent = stats
	
	local donate = Instance.new("IntValue")
	donate.Name = "Donated" -- Change "Money" to anything you want to name it like "Cash"
	donate.Value = 0 -- Change the value to how many you want when the player joins the game
	donate.Parent = stats
end)

Balance Leaderboard Handler (GlobalLBHandler):

local ds = game:GetService("DataStoreService")

local coinsODS = ds:GetOrderedDataStore("CoinsStats")


local timeUntilReset = 60


while wait(1) do
	
	
	timeUntilReset = timeUntilReset - 1
	
	script.Parent.Parent.ResetTime.Text = "Resetting in " .. timeUntilReset .. " seconds..."
	
	
	if timeUntilReset == 0 then
		
		timeUntilReset = 60
	
	
		for i, plr in pairs(game.Players:GetPlayers()) do
			
			coinsODS:SetAsync(plr.UserId, plr.leaderstats.Balance.Value)
		end
		
		for i, leaderboardRank in pairs(script.Parent:GetChildren()) do
			
			if leaderboardRank.ClassName == "Frame" then
				leaderboardRank:Destroy()
			end
		end
		
		
		local success, errorMsg = pcall(function()
			
			local data = coinsODS:GetSortedAsync(false, 10)
			local coinsPage = data:GetCurrentPage()
			
			for rankInLB, dataStored in ipairs(coinsPage) do
				
				
				local name = game.Players:GetNameFromUserIdAsync(tonumber(dataStored.key))
				local coins = dataStored.value
				
				
				local template = script.Template:Clone()
				
				template.Name = name .. "Leaderboard"
				
				template.PlrName.Text = name
				
				template.Rank.Text = "#" .. rankInLB
				
				template.Coins.Text = coins
				
				template.Parent = script.Parent				
			end			
		end)
	end
end

Donation Leaderboard Handler (GlobalLBRHandler):

local ds = game:GetService("DataStoreService")

local coinsODS = ds:GetOrderedDataStore("RobuxStats")


local timeUntilReset = 60


while wait(1) do
	
	
	timeUntilReset = timeUntilReset - 1
	
	script.Parent.Parent.ResetTimeR.Text = "Resetting in " .. timeUntilReset .. " seconds..."
	
	
	if timeUntilReset == 0 then
		
		timeUntilReset = 60
	
	
		for ie, plr in pairs(game.Players:GetPlayers()) do
			
			coinsODS:SetAsync(plr.UserId, plr.leaderstats.Donated.Value)
		end
		
		for ie, DonatRank in pairs(script.Parent:GetChildren()) do
			
			if DonatRank.ClassName == "Frame" then
				DonatRank:Destroy()
			end
		end
		
		
		local success, errorMsg = pcall(function()
			
			local data = coinsODS:GetSortedAsync(false, 10)
			local coinsPageR = data:GetCurrentPage()
			
			for robuxs, dataStored in ipairs(coinsPageR) do
				
				
				local name = game.Players:GetNameFromUserIdAsync(tonumber(dataStored.key))
				local Rbx = dataStored.value
				
				
				local robux = script.Robux:Clone()
				
				robux.Name = name .. "Leaderboard"
				
				robux.PlrNameR.Text = name
				
				robux.RankR.Text = "#" .. robuxs
				
				robux.CoinsR.Text = Rbx
				
				robux.Parent = script.Parent				
			end			
		end)
	end
end 
2 Likes

If you need more info on my problem, I took screenshots of the layout of each Leaderboard

Donation Leaderboard (Layout):

Screenshot (4)

Balance Leaderboard (Layout):

Screenshot (3)

Your topic is very lengthy and detailed, It makes people not really want to read it. But regardless, could you point out a part of the script that you think could potentially be the problem?

Sure but a part of which script? The Balance Leaderboard Script or the Donation Leaderboard script? I know that the leaderstats is fine.

1 Like

Both of these scripts are fine, when your saving your “Donation” data are you doing it specifically to the DataStore “RobuxStats”?

I mean I have a data saving script that saves my players’ leaderstats but I don’t know if that’s what you mean. However, it doesn’t cause issues for my “Balance” data on the Leaderboard or any other sets of data I have in my game.

So I think i’m saving my Donation data to my Datastore “RobuxStats” or to the server’s data saving script.

Double check where it’s being saved, as far as I’m concerned, the code looks like it works.

I just checked; my “Donation” Data is being saved to the “RobuxStats”. Thanks for your help btw

1 Like

Also Fastkingyaya, do you think this is a bug of some sort? Im planning on marking it in the bugs/glitches category.

Potentially, but It’s most likely your script. Roblox Studio may not be perfect, but I highly doubt its an issue with roblox. Sorry I couldn’t get back to you I was quite busy all day and yesterday.

Try recreating the “RobuxStats” code, or Copy/Paste it into another script.
Or if you haven’t already, check with prints to make sure everything works.

Ok, Thanks! It’s fine if you couldn’t get back to me, you’ve already helped me out with so much.

Hey, Great News!

I found out the core problem of why my donation leaderboard doesn’t work. Following your advice on checking with prints, I found that everytime my donation leaderboard refreshes a player, it prints out “Donation is not a valid member of Folder”.

From this, where do you think I should proceed?

It look like that the Donated is not found in the player leaderstats. In this line

plr.leaderstats.Donated.Value

If you play it from studio, check during the play whether or not your Donated stats exists inside your player leaderstats

I just checked. The donation value is not inside the player’s leaderstats. How do I make it inside the player’s leaderstats based on the leaderstats script I made?

In your PlayerAdded:Connect function, the leaderstats instance should be a Folder, not an IntValue

Try to change this

local stats = Instance.new("IntValue")

to this

local stats = Instance.new("Folder")

This is not the case, try reading the error a little more carefully next time.

@ste300000, you must be asking the script to find a folder and find the Object in that folder.
Basically, the line of code where you get the Donation.Value… the parent of Donation must not be the IntValue “leaderstats” Make only one leaderstats.

I get what you’re saying, but if the parent of Donation can’t leaderstats, how will my “Donation” data get linked up to the leaderboard? I’m using the IntValue leaderstats as a place to store my player’s Balance and Donation data.

Did it happen to give a line at which you got the Donated is not a vlid member of Folder error?

If it did give a line, l would like to see it.

It did give a line.

@fastkingyaya
the line it gave is
coinsODS:SetAsync(plr.UserId, plr.leaderstats.Donated.Value)
which is located on line 24