Bage don't works

image

local BadgeService = game:GetService("BadgeService")

local done = false
local function awardBadge(player, badgeId)
	-- Fetch badge information
	local success, badgeInfo = pcall(function()
		return BadgeService:GetBadgeInfoAsync(badgeId)
	end)
	if success then
		-- Confirm that badge can be awarded
		if badgeInfo.IsEnabled then
			-- Award badge
			local awarded, errorMessage = pcall(function()
				BadgeService:AwardBadge(player.UserId, badgeId)
				print("badge awarded")
				done = true
			end)
			if not awarded then
				warn("Error while awarding badge:", errorMessage)
			end
		end
	else
		warn("Error while fetching badge info!")
	end
end

game.Players.PlayerAdded:Connect(function(player)
	done = false
	repeat 
		awardBadge(player, 2124529269)
		wait(1)
	until done == true
	
end)

why it is 62% if it must be 100%?

So the badge works but the percentace is wrong? If it is like that, then you might as well delete this post, this is a Roblox problem, we can’t do anything about it. (This is not meant to be offensive)

The following is how the method works: For eg, if only 5 people owned this particular badge, it would be considered rare. The more people who own it, the less valuable it is.

And yes, Roblox automatically calculates the percentage, and I believe that’s the correct rate.

Was this badge added on the initial release of the game, or later on? If so, people who didn’t join after the badge got added wouldn’t get it. That’s perhaps the reason why.

I believe this is cause of how inaccurate the Badge Percentage can be calculated, my guess is that currently it takes the amount of unique players that first earns the badge, then divides it by the total number of visits that all players have joined the game, regardless if they have the badge or not

Further examples:

local UniquePlayers = 125
local TotalVisits = 750

local BadgeRarityResult = UniquePlayers / TotalVisits

print(BadgeRarityResult) --Output would probably be 16.67%

Try this?

local BadgeService = game:GetService("BadgeService")

local function awardBadge(player, badgeId)
	-- Fetch badge information
	local success, badgeInfo = pcall(function()
		return BadgeService:GetBadgeInfoAsync(badgeId)
	end)
	if success then
		-- Confirm that badge can be awarded
		if badgeInfo.IsEnabled then
			-- Award badge
			local awarded, errorMessage = pcall(function()
				BadgeService:AwardBadge(player.UserId, badgeId)
			end)
			if awarded then
				print("badge awarded")
				return true
			else
				warn("Error while awarding badge:", errorMessage)
				return false
			end
		else
			return true
		end
	else
		warn("Error while fetching badge info!")
		return false
	end
end

game.Players.PlayerAdded:Connect(function(player)
	local done = false
	repeat 
		done = awardBadge(player, 2124529269)
		wait(1)
	until done == true
end)
1 Like