Player not being awarded badge

A ‘follow up’ of my previous topic, i managed to find a solution to it but for some reason the player cannot be awarded the badge, i tried firing remote events but that wouldn’t work as the player randomly gets the badge upon joining, which i don’t want to happen
Script is a normal script found inside part which is in workspace.
image

Here is a code snippet:

ClickDetector.MouseClick:Connect(function(Player)
	local PGui = Player.PlayerGui
	PGui.InvPoster.Frame.Visible = true
	if value.Value < 5 then
		value.Value += 1
	elseif value.Value == 5 then
		local hasBadge = BS:GetBadgeInfoAsync(badgeNumber, Player.UserId)
		if hasBadge == nil then
			BS:AwardBadge(Player.UserId, badgeNumber)
		end
	end
end)

Is there any reason why you’re using GetBadgeInfoAsync() as opposed to UserHasBadgeAsync()?

GetBadgeInfoAsync() returns a dictionary, meaning your condition will never be nil and therefore the badge will never be awarded.

1 Like

You can simply use this instead.

ClickDetector.MouseClick:Connect(function(Player)
	local PGui = Player.PlayerGui
	PGui.InvPoster.Frame.Visible = true
	if value.Value < 5 then
		value.Value += 1
	elseif value.Value == 5 then
		pcall(function()
			BS:AwardBadge(Player.UserId, badgeNumber)
		end)
	end
end)

Maybe badge is not enabled or player already have one.
And, can you print error?

Tried this solution and somehow the player still earns the badge upon joining? (Which i don’t want clearly)