local BadgeService = game:GetService("BadgeService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local badgeIds = {1155034684402098, -- Add more badge IDs here
1155034684402099}
local function calculateBadgePercentage(totalBadges, ownedBadges)
if totalBadges == 0 then
return 0
end
return math.floor((ownedBadges / totalBadges) * 100)
end
local function updateBadgePercentage()
local success, result = pcall(function()
return BadgeService:CheckUserBadgesAsync(player.UserId, badgeIds)
end)
if not success then
warn("Error while checking badges for player", player.Name, ":", result)
return
end
local ownedBadgeIds = result
local totalBadges = #badgeIds
local ownedBadges = 0
for _, badgeId in pairs(badgeIds) do
if table.find(ownedBadgeIds, badgeId) then
ownedBadges = ownedBadges + 1
end
end
local percentage = calculateBadgePercentage(totalBadges, ownedBadges)
script.Parent.Text = percentage .. "%"
end
updateBadgePercentage()
Try this