My Global Leaderboard is conflicting with another Global Leaderboard

Can you try doing :WaitForChild("Donated").Value and then :FindFirstChild("Donated").Value? Also can you put a print right before line 24 and do print(plr.leaderstats.Donated.Value). Its more for debugging and seeing what’s happening. Just post any output errors you get.

What do you mean by inserting the :WaitForChild(“Donated”).Value and then add :FindFirstChild(“Donated”).Value?

I didn’t really understand what you mean by this so this is what my script looks like after following your advice.

 for i, plr in pairs(game.Players:GetPlayers()) do
			print(plr.leaderstats.Donated.Value)
			coinsODS:SetAsync(plr.UserId, plr.leaderstats:WaitForChild("Donated"))
			coinsODS:SetAsync(plr.UserId, plr.leaderstats:FindFirstChild("Donated").Value)
		end

Try only using this;

coinsODS:SetAsync(plr.UserId, plr.leaderstats:WaitForChild("Donated").Value)

Also check if there is another leaderstats.

If there is then this could be the problem.
If there is not, show me a screenshot of the children of player (Example below)
image

When I used your code above, it printed this instead of the “Folder” print discussed on the last few replies:
Screenshot (6)

Also, here is the children of the player that you’ve asked for:
Screenshot (7)

This is an extreme issue. The reason the code doesn’t work is because you have two leaderstats. The code finds the first leaderstats and tries to find “Donation” but gets back nothing.
There is a second script or second part of a script that makes leaderstats. That is the problem. Make only one leaderstats.

Check each script for a leaderstats value if you don’t know where it is.

Hello, the mistake is probably in this part

image

You need to set leaderstats as a Folder, not as an IntValue. Currently it tries to find Donated as an attribute of leaderstats object, which its not.

So you write that part like this instead:

local stats = Instance.new("Folder")
stats.Name = "leaderstats"
stats.Parent = p

Otherwise, as I have seen the older posts in this thread, it might be because you have two leaderstats. You could parent the Donated value to the leaderstats folder that is already created instead of creating a new one.

I don’t know what’s creating another leaderstats folder for Balance though. My two scripts for the leaderboards doesn’t seem to be creating another leaderstat (unless I’m not aware of a key detail in it). I am only aware that I have created one leaderstat and it was the leaderstat mentioned in the beginning of this thread,

I just figured something out.

The first leaderstats with the Balance value only seems to be the current balance of my players.
The second leaderstats is what my player’s Balance/Donations values are when they first joined the game, which is 0.

All of these things occurred in a single leaderstats script mentioned in the beginning of this post.

What I’m trying to do is to get the Donation value to be in the first leaderstats so that it can represent the player’s current Donation value. Once that’s done, the global leaderboards should work. The problem is that I don’t know how to get the player’s current Donation value onto the first leaderstat, since I thought the Donation Leaderboard Handler already did that.

You could try finding through the scripts in your Server Script Service, which create leaderstats folder, otherwise you could directly parent it to the leaderstats folder inside the Player.

If you want to see all the scripts in your game;

  1. On the top of your explorer tab click “Filter Workspace”
  2. Then type “Script”.

and it should show you all of the scripts in your game. Check each of them for the .PlayerAdded event (example below).

game.Players.PlayerAdded:Connect(function()

end)

If you see something like this then check for leaderstats on the inside. If it’s not obvious, you can always go into the script and click (Ctrl + F)


type in, “leaderstats” and it should show you all words that have “leaderstats” in it. It should be highlighted in yellow as you scroll through the script.


If you find that “leaderstats”, simply remove it, and everything should work.

I checked all of the scripts and not one of them had the .PlayerAdded event followed by leaderstats except for that one script I mentioned in the beginning.

Also, if the Balance is in both leaderstats, why can’t the Donation value do the same? I don’t understand why this isn’t a possibility.

Something external must be creating it then, such as a plugin.

You can always just change this;

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)

To this

game.Players.PlayerAdded:connect(function(p)
	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 = p:WaitForChild("leaderstats")
end)

and it should work fine.

1 Like

Yeah, that seems to fix the leaderboard problem.

Thank you and all the other devs for helping me fix this issue.