Give badge on LeaderStats Value

This is what I get. It’s the only thing I get.


Also it’s named lolxd because I was testing it real quick.

I’m thinking this is because the leaderstats is only put into the player after they have become the owner of a tycoon and it times out.

game.Players.PlayerAdded:Connect(function(Player)
	repeat
		task.wait(0.5)
	until Player:FindFirstChild("leaderstats")
	local Cash = Player.leaderstats:WaitForChild("Cash")

	Cash:GetPropertyChangedSignal("Value"):Connect(function()
		print(tonumber(string.gsub(Cash.Value, ",", "")))
		if tonumber(string.gsub(Cash.Value, ",", "")) >= 500 then
			print("Over 500")
		end
	end)
end)

leaderstats should be a folder, not an IntValue.


oh lol I thought it was a virus.

No, leaderstats can be an IntValue. It is the way Zed’s Tycoon Kit handles it. And as you could see, it showed perfectly fine.

WaitForChild is a thing, you know. You can also just do cash.value:gsub(",", “”) as well.

Yes, it can, but it’s not really there for any reason…

They probably have a reason for it, but even if they don’t, it really doesn’t change much lol

This is what I got.
image

Yes, but obviously the WaitForChild seems to be timing out.

Yeah, true.

Should not be happening. I’m also not sure why the value has to be a string value now, since the leaderboard handles that for everyone now.

Well, then the problem is my gsub. Try printing what my gsub returns and I can fix it from there.

game.Players.PlayerAdded:Connect(function(Player)
	repeat
		task.wait(0.5)
	until Player:FindFirstChild("leaderstats")
	local Cash = Player.leaderstats:WaitForChild("Cash")

	Cash:GetPropertyChangedSignal("Value"):Connect(function()
		print(string.gsub(Cash.Value, ",", ""))
		if tonumber(string.gsub(Cash.Value, ",", "")) >= 500 then
			print("Over 500")
		end
	end)
end)

Yea, Zed’s Tycoon Kit stopped receiving updates years ago I believe.

It doesn’t return anything bruh

Wait where do I put the return. Or did you already put it

I just tested this myself. I forgot that gsub returned a second value of how many commas were removed.

game.Players.PlayerAdded:Connect(function(Player)
	repeat
		task.wait(0.5)
	until Player:FindFirstChild("leaderstats")
	local Cash = Player.leaderstats:WaitForChild("Cash")

	Cash:GetPropertyChangedSignal("Value"):Connect(function()
		local amt = string.gsub(Cash.Value, ",", "")
		if tonumber(amt) >= 500 then
			print("Over 500")
		end
	end)
end)

Wait, it returned my cash.
The first line is my cash. 161,945,806
or 161million.
The only thing is that the number was comparing it with nil.

It should work properly if you used the tonumber(amt) instead of the tonumber(string.gsub(Cash.Value, “,”, “”)). I tested it myself and it worked perfectly fine for me. But might as well add another print.

game.Players.PlayerAdded:Connect(function(Player)
	repeat
		task.wait(0.5)
	until Player:FindFirstChild("leaderstats")
	local Cash = Player.leaderstats:WaitForChild("Cash")

	Cash:GetPropertyChangedSignal("Value"):Connect(function()
		local amt = string.gsub(Cash.Value, ",", "")
		print(amt, tonumber(amt))
		if tonumber(amt) >= 500 then
			print("Over 500")
		end
	end)
end)
2 Likes

My game is broken, the collector isn’t working bruh :sob:
lol i have to try to fix it

Alright, I will be going to bed soon, but I will try and check again before I do. Just tell me if there are any problems.

Omg it works. the only thing is. I reseted the data for every single player that ever played the game lol