Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Global Player Badge Leaderboard - Badge Counter?

I'm lost of words on how to create this. I'm looking to script a player badge counter that tracks(counts) each badge and is valued to a leaderboard. I legit could not find a way to make this work. I've seen games with this feature but I can not create it. I've tried countless times, over weeks and can't get it working.

1 answer

You can make an IntValue that adds up each time you get a badge.

ServerScript in ServerScriptService

game.Players.PlayerAdded:Connect(function(player)
	local leaderstats = Instance.new("Folder", player)
	leaderstats.Name = "leaderstats"
	
	local badgevalue = Instance.new("IntValue", leaderstats)
	badgevalue.Name = "BadgeValue"

ServerScript that detects when a player gets a badge you can put this almost anywhere. For an example, I'm going to make the value go up and also it would award the badge whenever you touch a part

local part = script.Parent -- your part location
local badgeservice = game:GetService("BadgeService")
	
game.Players.PlayerAdded:Connnect(function(player)
		part.Touched:Connect(function()
			badgeservice:AwardBadge()
			player.leaderstats.BadgeValue.Value = player.leaderstats.BadgeValue.Value + 1
		end)
end)

Tell me if this works lol.

This discussion is preserved as it was. New answers, comments, and votes are closed.