Badge Not Being Rewarded

I have this badge in my game, there is no errors in the code and all the print statements say I am getting the badge nothing else but when I play the game on the Roblox Client that badge does not get rewarded to me and I have used other accounts and they don’t get the badge either… Is it a Roblox bug or is my code incorrect.

local ScreenGui = game.StarterGui.ScreenGui
local PoisonEnding = ScreenGui.PoisonEnding
local BadgeService = game:GetService(“BadgeService”)
local badge = 6050572553
local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local BadgeGiver = ReplicatedStorage:FindFirstChild(“BadgeGiver”)
local place = 17666646122
local serverID = game.JobId
local TeleportService = game:GetService(“TeleportService”)

BadgeGiver.OnServerEvent:Connect(function(plr)

PoisonEnding.Visible = true

local hasBadge = BadgeService:UserHasBadgeAsync(plr.UserId, badge)

if hasBadge then
	print(plr.Name.." Has This Badge")
	wait(.25)
	TeleportService:TeleportToPlaceInstance(place, serverID, plr)
else
	BadgeService:AwardBadge(plr.UserId, badge)
	print(plr.Name.." Has Been Awarded Badge")
	wait(.25)
	TeleportService:TeleportToPlaceInstance(place, serverID, plr)
end

end)

2 Likes
local function AwardBadge(player, badgeId)
		task.wait(0.1)
		local success, badgeInfo = pcall(function()
			return BadgeService:GetBadgeInfoAsync(badgeId)
		end)
		if success then
			-- Confirm that this badge can be awarded
			if badgeInfo.IsEnabled then
				-- Award that badge
				local awarded, errorMessage = pcall(function()
					BadgeService:AwardBadge(player.UserId, badgeId)
				end)
				if not awarded then
					warn("Error while awarding badge:", errorMessage)
				end
			end
		else
			warn("Error while fetching badge information")
		end
	end

works for me
check if the badge is active for your game and check if the Ids are correct too - i had this issue once

I have added your code and it gives the warning message (“Error while fetching badge information”), what shall I do?

Ensure that the Badge ID you’re providing is valid. If it is valid,

Change this line:

to this:

warn(`Error while fetching badge information: {badgeInfo}`)

That way, the error that is returned from the pcall will appear in the output. This will make it easier to debug the issue.

2 Likes

Okay it says badgeID is invalid or does not exist, should I just recreate the badge?

There we go. Now the problem is more clear. Can you ensure the badge Id you’re providing when you call the AwardBadge function you created is the correct ID?

2 Likes

It is the same ID as the badge I will just re-create the badge and tell you if it works.

1 Like

I have been using a different ID this whole time, thanks for your assistance.

2 Likes

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