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
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
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?