How to tell when a badge has been awarded?

I’m trying to find an event that gets fired when a player earns a badge. There’s nothing on the BadgeService hub, and while I could create a remote event and fire that whenever AwardBadge is done, however I wanna know how the default badge notice knows when to show up (as trying to make my own notification system to show badges earned)

2 Likes

I’m not sure if there is any method that does that. I guess the best thing to do is use RemoteEvents, just saying.

1 Like

Why not just do it after doing AwardBadge method?

1 Like

There is no event, and there will never be an event because literally you reward the badge, so you always know when it was rewarded.

1 Like

Oh and by the way, the event for it is locked for CoreGuis only.

I think you can use BadgeService:UserHasBadgeAsync() for this scenario.

But this only can be called from server script or module scripts, so you have to use remote functions to make it work:

(code untested)

--local script

local badgeOwned = path_to_remoteFunction:InvokeServer(badge_id)

if badgeOwned then
    print("Player owns this badge.")
end
--server script

path_to_remoteFunction.OnServerInvoke = function(plr,badgeId)
    local success,hasBadge = pcall(function()
        return BadgeService:UserHasBadgeAsync(plr.UserId,BadgeId)
    end)

    if success then
        return hasBadge
    else
        warn("Something went wrong.")
    end

end
1 Like

cc @Quwanterz

Reason why I was asking this question. AwardBadge has to be done on the server. I was hoping there’d be an event that the client could pick up, instead of having to manually create a remote for this

I believe you will have to stick with the RemoteEvent method as the event for detecting it is locked for CoreGuis.

This is the locked method that the CoreGuis are only allowed to use:

There was also a topic suggesting this event, however it is not implemented because the notification is already made by Roblox.

1 Like