Roblox Badge checking

I wanna do a thing to check if players have certain Roblox Badges.
I’m not talking about the silly badges that players get when they join. I’m talking about the weird badges you get for having a high visitor count, playing this platform for a year, or doing things before 2015.
I do not know what their IDs even are (if they even have IDs), and I kinda wanna include some easter eggs in my game where you get things like decorations depending on what Roblox Badges you have.

1 Like

you coulddd use
the CheckUserBadgesAsync in the BadgeService : )

2 Likes

alas, no dice.

This isn’t a Service thing, it’s more of an API thing
I found you can use https://accountinformation.roblox.com/docs/json/v1 this to see a player’s badges

1 Like

alas… it would seem roblox put a limit there.
image

2 Likes

You can’t call it from in-game without using HttpService & routing it through a proxy first, but you could use this api: https://accountinformation.roblox.com/v1/users/84902541/roblox-badges

2 Likes

i guess i need to find out how to do the proxy bit, and hopefully that works

1 Like
local Players = game:GetService("Players")
local HttpService = game:GetService("HttpService")
local Players = game:GetService("Players")

local function onPlayerAdded(player)
	local userId = player.UserId
end

Players.PlayerAdded:Connect(onPlayerAdded)

-- Badge IDs to check
local badgeIds = {
    [3] = "Combat Initiation",
    [4] = "Warrior",
    [16] = "Homestead",
    [18] = "Builders Club"
}

local url = "https://accountinformation.roblox.com/v1/users/" .. userId .. "/roblox-badges"

local success, response = pcall(function()
    return HttpService:GetAsync(url)
end)

if success then
    local badges = HttpService:JSONDecode(response)
    
    for _, badge in pairs(badges) do
        if badgeIds[badge.id] then
            print("achoo")
        end
    end
else
    warn("Failed to retrieve badges: " .. response)
end

So this is a pretty tricky thing to do, as it involves usage of Roblox API’s but I think this code might be correct, or if not, it sure will be a major hint. I gave each rare Roblox badge their id’s, and used the API to check if the player has the badges or not, if they did, then i used a placeholder print("achoo") which you can change to whatever special thing or perk you will grant them.
Keep in mind that you will have to modify this!

for _, badge in pairs(badges) do
        if badgeIds[badge.id] then
            print("achoo")
        end
    end
2 Likes
type badge = {id: number, name: string, description: string, imageUrl: string}
local function getRobloxBadges(userId: number): {badge}
	--proxy this(for example replace roblox.com with roproxy.com in the url)
	local url = "https://accountinformation.roblox.com/v1/users/"..userId.."/roblox-badges"
	--pcall this, it can error(for example internal server error)
	local response = game.HttpService:GetAsync(url)
	local data = game.HttpService:JSONDecode(response)
	return data 
end

local userId = 1 --replace with your user id
local badges = getRobloxBadges(userId)

for _, badge in pairs(badges) do
	print(badge.id, badge.name)
end

If you want to iterate through the badges in a sorted manner, you will have to choose a property to sort them by, for example here we print them in an ascending order by id:

local function getBadgeById(badges: {badge}, id: number): badge
	for _, badge in pairs(badges) do
		if badge.id == id then return badge end
	end
end

local ids = {}
for _, badge in pairs(badges) do table.insert(ids, badge.id) end
table.sort(ids)

for _, id in pairs(ids) do
	local badge = getBadgeById(badges, id)
	print(badge.id, badge.name)
end
2 Likes

Thanks for helping! I needed to do proxy shenanigans and it worked.
image

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