How to Give a Badge to Specific Players?

Hello Developers,
I would like to try and create a script that can award only specific people a badge upon entering the game. Not the entire server, just certain players via their UserId. How can I do this? I’ve searched over YouTube, DevForums, Reddit, other sites, I can’t find anything on how I can do this.

You can use AwardBadge, remember to verify the stuffs you need ( like the thing to give badges to only specific people )

How can I do that? I understand somewhat the AwardBadge, but nothing else. (Like using local UserId = 0000000?)

Use BadgeService:AwardBadge(0000000, BadgeId)


local playerid = 0 -- add player id here.
local badgeID = 2125019685 -- badge id here.

game.Players.PlayerAdded:Connect(function(player)
	if player.UserId == playerid then
		for i, v in pairs(game.Players:GetChildren()) do 
			wait(1)
			game:GetService("BadgeService"):AwardBadge(v.UserId, badgeID)
		end
	end
end)
4 Likes
local players = game:GetService("Players")
local badges = game:GetService("BadgeService")
local userHasBadge = badges.UserHasBadgeAsync
local awardBadge = badges.AwardBadge

local userIds = {1, 2, 3} --Put user IDs here.
local badgeId = 0 --Change this to the badge's ID.

local function onPlayerAdded(player)
	if table.find(userIds, player.UserId) then
		local success, result = pcall(userHasBadge, badges, player.UserId, badgeId)
		if success then
			if not result then
				local success2, result2 = pcall(awardBadge, badges, player.UserId, badgeId)
				if success2 then
					if result2 then
						print("Badge awarded!")
					end
				else
					warn(result2)
				end
			end
		else
			warn(result)
		end
	end
end

players.PlayerAdded:Connect(onPlayerAdded)

I was unsatisfied with the post marked as the solution.

9 Likes