So whe BBC you get a badge a core GUI shows up. It only shows whether you get it not have it. Is there a term for this? I would appreciate an example of its use.
There is no way for you to tell when a badge is awarded. You would have to create that type of function yourself. There is an event for this, but it is locked to core scripts.
That would be if they have it. Not when they get it.
The term would just be “Badge Awarded”. There is no current event to see if it was awarded or not.
You could just use this:
local Badge = 000000 -- BadgeId!
local BadgeService = game:GetService("BadgeService") -- Get the badge service!
-- Example:
game:GetService("Players").PlayerAdded:Connect(function(Player) -- Get when a player joins.
BadgeService:AwardBadge(Player.UserId, Badge) -- Award the badge.
end)
game:GetService("LogService").MessageOut:Connect(function(message, Type)
if Type == Enum.MessageType.MessageWarning then
local msg = message:match("") -- Put the scripts name here!
if msg then -- Check if there's a warning.
print("Error occurred while awarding badge, try again later.") -- Print there's an error, because the user already had the badge.
else
print("Successfully rewarded badge!") -- Otherwise, the badge got awarded successfully!
end
end
end)
This is untested, but should work just fine for you! Let me know any questions regarding this topic!
(Sources):
https://developer.roblox.com/en-us/api-reference/class/BadgeService
https://developer.roblox.com/en-us/api-reference/function/BadgeService/AwardBadge
https://developer.roblox.com/en-us/api-reference/lua-docs/string
1 Like