So I want to make a script that counts badges but I don't know-how. For example.
print(the number of badges of a player)
Use the BadgeService: https://developer.roblox.com/en-us/api-reference/class/BadgeService
You could create a table of badges that your game owns:
local badgeIDs = {}
Then iterate through the table with pairs/ipairs and use :UserHasBadgeAsync (link: https://developer.roblox.com/en-us/api-reference/function/BadgeService/UserHasBadgeAsync) then for each badge the player owns, count up by 1.
local badgeService = game:GetService("BadgeService") local badgesOwnedCount = 0 for index, badgeID in ipairs(badgeIDs) do if badgeService:UserHasBadgeAsync(player.UserId, badgeId) then end end
Then where you see the if statement, under it, you just add one to the badgesOwnedCount for each badge the player owns like so:
badgesOwnedCount += 1 -- OR: badgesOwnedCount = badgesOwnedCount + 1