I want to award a badge to everyone in a server when the server has 30 players at once

  1. What do you want to achieve? I want to award all players in a server with a badge when the server has 30 players at the same time.

  2. What is the issue? There are no other developer forums that have the same question.

  3. What solutions have you tried so far? I have found no forum posts asking the same question.

I would be happy if someone could help me with this, since there are no other people that have asked the same before.

1 Like
local badgeService = game:GetService("BadgeService")

local badge_ID = 12345 -- Badge ID here

local function awardBadge(player)
	badgeService:AwardBadge(player.UserId, badge_ID)
end

local function check()
	if #game.Players:GetPlayers() >= 30 then
		for _,v in pairs(game.Players:GetPlayers()) do
			awardBadge(v)
		end
	end
end

game.Players.PlayerAdded:Connect(function(player)
	check()
end)

That’s a quick reply. thank you very much!

1 Like

For those who want to use this as well, you can change the “30” part with any number.