Award badge for currency milestones

How can i make it so that a player gets a badge when they reach, say, 100 coins, or 500, etc? I don’t know where i can put this script. Thank you!

local BadgeService = game:GetService("BadgeService")

local badgeID = 000000
local Currency = "Coins"
local AmountNeeded = 100

game.Players.PlayerAdded:Connect(function(Player)
	
	local leaderstats = Player:WaitForChild("leaderstats")
	
	if leaderstats then
		leaderstats[Currency]:GetPropertyChangedSignal("Value"):Connect(function()
			if leaderstats[Currency].Value >= AmountNeeded then
				BadgeService:AwardBadge(Player.UserId, badgeID)
				print("awarded badge!")
			end
		end)
	end
end)

I wrote this up pretty quickly, you can maybe add a check to see if the badge is already owned by the user to improve performance.

2 Likes

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