How would I make a "Met a Dev" badge?

I already know how to make a script that gives a player a badge for being in the same server as the owner, and I think I know how to do that for the whole dev team too, but how would I make it so that there is only 1 script used to give the player a badge for meeting a dev? Sorry if it’s a bit confusing just ask if you’re confused.

Edit: Just because, here’s the game link (The game isn’t fully public yet though.): The Backrooms: Reimagined - Roblox

1 Like

Make a list of UserId of the devs and put that at the top of your script and then just do

if table.find(Ids, Player.UserId) then
-- Code here
end

( Ids is the table of UserIds and Player is the Player that joined ).

2 Likes
game.Players.PlayerAdded:Connect(function(player)
if game.Players:FindFirstChild(devName) then
--award
end
end
1 Like

So something like

local badgeService = game.BadgeService

local id = 0 --[[The Badge ID]]--

local Ids = {playerid1, playerid2}

game.Players.PlayerAdded:Connect(function()
	if table.find(Ids, Player.UserID) then
		local Players = game.Players:GetPlayers()
		for i = 1, #Players do
			local Player = Players[i]
			if not badgeService:UserHasBadgeAsync(Player.UserId, id) then
				badgeService:AwardBadge(Player.UserId, id)
			end
		end
	end
end)
2 Likes

Yes that is indeed what i think it would be.

This wont actually work

This text will be blurred

Actually you need to include the Player argument in the event connection

game:GetService("Players").PlayerAdded:Connect(function(Player)

local Devs={"DeveloperUsername"}
local BadgeService = game:GetService("BadgeService")

local badgeId=0000 -- change to your badge id
local function _GiveBadge(Player)
-- Fetch badge information
	local success, badgeInfo = pcall(function()
		return BadgeService:GetBadgeInfoAsync(badgeId)
	end)
	
	if success then
		-- Confirm that badge can be awarded
		if badgeInfo.IsEnabled then
			-- Award badge
			local success, result = pcall(function()
				return BadgeService:AwardBadge(player.UserId, badgeId)
			end)
			
			if not success then
				-- the AwardBadge function threw an error
				warn("Error while awarding badge:", result)
			elseif not result then
				-- the AwardBadge function did not award a badge
				warn("Failed to award badge.")
			end
		end
	else
		warn("Error while fetching badge info: " .. badgeInfo)
	end
end)

game.Players.PlayerAdded:Connect(function(Player)
    if table.find(Devs,Player.Name) then
         for i, v in pairs(game.Players:GetPlayers()) do
             _GiveBadge(v)
         end
    else
       local Found=nil
       for i,  v in pairs(Devs) do
           if game.Players:FindFirstChild(v) then
              Found=true
              break
           end
       end
       if Found==true then _GiveBadge(Player) end
    end
end)

Well I have a joined badge with the code I showed (Roughly) that works just fine.

Is there a way to use the same code, but with player IDs?

Just replace it with the UserId’s and do

if table.find(Devs, Player.UserId then

instead of

if table.find(Devs, Player.Name then

(replace the dev names with their UserId’s)

You use the variable “Player” when it is not defined, and if it was defined you declare it again with Players[i]
Here is my solution:

local Players = game:GetService("Players")
local BadgeService = game:GetService("BadgeService")
local developerIds = {1,2,3476883826}; -- insert user ids here
local badgeId = 0; -- badge id here
Players.PlayerAdded:Connect(function(plr)
    if table.find(developerIds,plr.UserId) then
        for _,v in ipairs(Players:GetChildren()) do
            if v ~= plr and not BadgeService:UserHasBadgeAsync(v.UserId, badgeId) then
                BadgeService:AwardBadge(v.UserId,badgeId)
            end
        end
    end
end)
2 Likes

I’ll try that and see if it works.

if anything works also let me know cuz I am also searching up for a code with the id :eyes:

This does not work. The script I used to give the “Met the Owner” badge worked. But this code you posted does not.

Did it throw an error? And how did you test it?

Shouldn’t it be for i,v in (code stuff) and not for _,v in (code stuff)?

1 Like
1 Like

Ah ok then. Maybe just check over the code a bit since in studio it isn’t showing errors.
Edit: I’m not the best at scripting, but the code looks fine to me.

1 Like

I have just tested, and the script seems to work perfectly fine for me in the latest version of ROBLOX Studio, Could you please show me how you edited it? (as in replaced badgeid variable etc)
By the way, since you tested it in Studio, I must say that the code doesn’t give the badge to the dev.

1 Like