Badge award when a player has enough stats in the game on the leaderboard

What I want to do is when a player has 100 strength in the leader stats they will gain a badge
I made around 3 badges but I still don’t get how to make the player get the badge
I’ve looked at a couple of things but it didn’t quite help.
Help would be appreciated

I don’t know if you’ve already looks at this or not but it should help you with generally giving them the badge.

As for giving them the badge when they have a certain leaderstats amount you can just check their leaderstats every time it changes and check if it’s a certain value.

1 Like
local BadgeService = game:GetService("BadgeService")

local badgeID = 000000
local Currency = "Strength"
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
				if BadgeService:UserHasBadgeAsync(Player.UserId, badgeID) then
					return
				end
				BadgeService:AwardBadge(Player.UserId, badgeID)
				print("awarded badge!")
			end
		end)
	end
end)

2 Likes

Firstly, Use the badge service to check if the player already owns the badge or not and then use badge service again to award the badge. it’s really simple

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