After staying in my game for a while, this one error occurred on this line:
if not BadgeService:UserHasBadgeAsync(player.UserId, v) then
Events.awardBadge(player,v)
end
Is this a problem with badgeservice or is this just a problem with something on my code. I am not sure how to replicate this problem because it was pretty random. I tried to just remove this if not check and let the pcall inside of award badge do the check.
Any function that calls to a external source can error. It’s recommended to wrap it in a pcall and check if it was successful
local Success, Result = pcall(function()
return BadgeService:UserHasBadgeAsync(player, v)
end)
-- result is whether or not they have the badge if successful, otherwise, it's the error message
if Success and Result then
-- try to award badge with pcall
end