I haven't been able to test this code yet, but would this be an efficient way to award a badge to all players at once?
function awardWin() local winnerBadgeId = 545006970 for i, player in ipairs(game.Players:GetPlayers()) do wait(0.1) script.Parent.Achievement:Play() local a = game:GetService("BadgeService") a:AwardBadge(player.userId,winnerBadgeId) end end
The first thing you want to do is figure out when to award badges. You can do this by integrating the badge awarding process directly in the loop controlling the progression of rounds, and checking whether the round matches the required round to award the badge for.
You can use the AwardBadge method to actually award Badges to players. Here's an example of the AwardBadge method being used, assuming the variable player references the player that will earn the badge and the variable badgeId is the number ID of the badge asset.
game:GetService("BadgeService"):AwardBadge(player.userId, badgeId)
To award all players, you can just use a simple loop iterating through all of the players in the game. The line of code above will turn into...
for _, player in pairs(game.Players:GetPlayers()) do game:GetService("BadgeService"):AwardBadge(player.userId, badgeId) end
for _, player in pairs(game.Players:GetPlayers()) do game:GetService("BadgeService"):AwardBadge(player.userId, badgeId) end You can read more about BadgeService on the Wiki.
Info from
If this helps, Please mark this question answered!