How do i check how many badges a plr has from my game?

Im trying to make a module that checks how many badges a plr has from my game.
I have tried multiple ways to achieve this but i cannot get it to work.

Eventually when the plr has for example 1 badge and he types something in the chat it will show [I] [grouprank] plr.Name.

Module 1:

function module.AchievableRanks()
	local AchievableRoles = {
		"I"; -- 1 Badge
		"II"; -- 3 Badges
		"III"; -- 7 Badges
		"IV"; -- 12 Badges
		"V"; -- 18 Badges
		"VI" -- 25 Badges
	return AchievableRoles

Module 2:

function module.BadgeIDs()
	local AchievableRoles = {

		2124972910; -- You Joined!
		2124972899 -- Met The Creator!

	return AchievableRoles

Module 3: The codes shown above are fine, This is the one im trying to get fixed.

-- // Services
local BadgeService = game:GetService("BadgeService")
local PlayerService = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerScriptService = game:GetService("ServerScriptService")

-- // Modules
local Ranks = require(ReplicatedStorage.Modules["Ranks-Badges"].Ranks)
local chatService = require(ServerScriptService:WaitForChild('ChatServiceRunner'):WaitForChild('ChatService'))

-- //  Variables
local groupId = 7628430
local count = 0

-- // Table
local module = {}

-- // Functions
local function doSomethingWithBadge(BadgeName, badgeId)
	local s, e = pcall(function()
		return BadgeService:GetBadgeInfoAsync(badgeId)
	if s then return e end
	return nil

function module:CreateChatTags(plr)
	local speaker = chatService:GetSpeaker(plr)
		if PlayerService[plr]:IsInGroup(groupId) then        
		local PlayerRank = PlayerService[plr]:GetRoleInGroup(groupId)
			--[[for badgeName, badgeId in pairs(Ranks.BadgeIDs()) do
					local badge = doSomethingWithBadge(badgeName, badgeId)
					if badge ~= nil then
		for _, id in ipairs(Ranks.BadgeIDs()) do
			local Success, Res = pcall(function()
				return BadgeService:UserHasBadgeAsync(plr.UserId, id)
			speaker:SetExtraData('NameColor', Color3.fromRGB(255, 255, 255))
			speaker:SetExtraData('Tags', {{TagText = PlayerRank, TagColor = Ranks.GroupRanks()[PlayerRank]}})    
			speaker:SetExtraData('NameColor', Color3.fromRGB(255, 255, 255))
			speaker:SetExtraData('Tags', {{TagText = "Guest", TagColor = Color3.fromRGB(255, 255, 127)}})

return module

I would personally make a table of badge Ids in a module, connect a PlayerAdded event to a for loop to check if they have each badge, and then cache that data into a storage internally into the script or by making a folder of their badges.

personally, what i would do, is make a table of ALL the badges inside of your game and make a badge counter. when a player joins, loop through the badges and check if they have one. if they have 1 of them, add + 1 to the badge counter