Awarding badge to someone

Hey devs,

So I wanted to make “Met the admin” badge in my experience.
So i tried taking already existing script from “Met the owner” badge. I tried changing ID and other things, but it didnt worked.

Basically Admin in my experience is my friend, so the ID used in it is my friend’s ID.

Can someone please help me please?

Script:

local BadgeService = game:GetService("BadgeService")

local badgeId = 1182597658936257

local function giveBadge()
	for _,player in pairs(game.Players:GetPlayers()) do
		if not BadgeService:UserHasBadgeAsync(player.UserId,badgeId) then
			BadgeService:AwardBadge(player.UserId,badgeId)	
		end
	end	
end

game.Players.PlayerAdded:Connect(function(player)
	if player.UserId == game.3720874559 then
		giveBadge()
	end
end)

if game.Players:GetPlayerByUserId(game.3720874559) then
	giveBadge(player.UserId,badgeId)
end

Heya! Your script is good! One small mistake is

Also you don’t need the last if statement.

You shouldn’t put game. before only put your user id

local BadgeService = game:GetService("BadgeService")

local badgeId = 1182597658936257

local function giveBadge()
	for _,player in pairs(game.Players:GetPlayers()) do
		if not BadgeService:UserHasBadgeAsync(player.UserId,badgeId) then
			BadgeService:AwardBadge(player.UserId,badgeId)	
		end
	end	
end

game.Players.PlayerAdded:Connect(function(player)
	for i,plrs in pairs(game.Players:GetPlayers()) do
		if plrs.UserId == 3720874559 then
			giveBadge()
		end
	end
end)

Also you could add a check when the player joins the game checking if you are in it so people joining the server when you are already in one also gets it!

(I didn’t test the script because I can’t really access studio, tell me if there are any errors!)

1 Like

Sure i will test it, but i need to wait for my friend to go online, just a question, how can i add that check? I was about to the topic about it too.

You can always use an alt account to test stuff like this.

1 Like

Yep, the script is working! Thank you so much man!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.