Met Dev badge not working

Hi some I’m trying to make a meet Dev script but it isn’t working I’m trying to have more then one person. Please help from John! :smiley:

local BadgeService = game:GetService("BadgeService")
local BadgeID = 2124495817

game.Players.PlayerAdded:Connect(function(Player)
if game.Players:FindFirstChild("Nanonauts, Strongjohnf, Nanoswamp") then
	for i, Plr in pairs(game.Players:GetPlayers()) do
		BadgeService:AwardBadge(Plr.userId, BadgeID)
	end
  end
end)
1 Like
if game.Players:FindFirstChild("Nanonauts, Strongjohnf, Nanoswamp") then

It seems you’re misusing FindFirstChild by checking to see if a player named “Nanonauts, Strongjohnf, Nanoswamp” exists. Try editing the statement to check the newly spawned player’s name:

if Player.Name=="Nanonauts" or Player.Name=="Strongjohnf" or Player.Name=="Nanoswamp" then
1 Like

Didn’t work.

I have modified your code adjusting it to what @ChipioIndustries has mentioned above. All I did was create a function to check if any of the developers are in the server and return the boolean true if they are. This function is called when a player joins to award passes to the players who met the developer and don’t own the badge.

Let me know if this works.

local BadgeService = game:GetService("BadgeService")
local BadgeID = 2124495817

function CheckDevs()
	for _, player in pairs(game:GetService("Players"):GetPlayers()) do
      if player.Name == "Nanonauts" or player.Name == "Strongjohnfgamer" or player.Name == "Nanoswamp" then
          return true
      end
   end
end

game.Players.PlayerAdded:Connect(function(Player)
	if CheckDevs() then
		for i, Plr in pairs(game.Players:GetPlayers()) do
			if BadgeService:UserHasBadge(Plr.UserId, BadgeID) == false then -- Check if they don't own the badge first.
				BadgeService:AwardBadge(Plr.userId, BadgeID)
			end
		end
	end
end)
1 Like

Didn’t work maybe because It’s in a file or the fact I’m cutting out Nanonauts in the script.

I did notice that your name was cut out and I fixed it. Also, make sure the player that is testing doesn’t own the badge and use the code that I posted above. See if it works now.

2 Likes
local BadgeService = game:GetService("BadgeService")
local Players = game:GetService("Players")

-- change these
local OWNER_ID = 212423 -- can use game.CreatorId for published places
local BADGE_ID = 1

local ownerInGame = false

local function playerAdded(newPlayer)
	if newPlayer.UserId == OWNER_ID then
		-- if new player is the owner, set ownerInGame to true and give everyone the badge
		ownerInGame = true
		for _, player in pairs(Players:GetPlayers()) do
			-- don't award the owner
			if player ~= newPlayer then
				BadgeService:AwardBadge(player.UserId, BADGE_ID)
			end
		end
	elseif ownerInGame then 
		-- if the owner is in the game, award the badge
		BadgeService:AwardBadge(newPlayer.UserId, BADGE_ID)
	end
end

local function playerRemoving(oldPlayer)
	if oldPlayer.UserId == OWNER_ID then
		-- set ownerInGame to false
		ownerInGame = false 
	end
end

-- listen for players joining and leaving
Players.PlayerAdded:Connect(playerAdded)
Players.PlayerRemoving:Connect(playerRemoving)

-- fire playerAdded for existing players
for _, player in pairs(Players:GetPlayers()) do
	playerAdded(player)
end

– this could’ve worked to i think, but CreditsMix’s scripts are always better!

2 Likes

You shouldn’t be doing this,

@CreditsMix
Your code contains a lot of bluff in the function , there is a lot of extra code , also your code gets the job done, but it uses usernames which is what shouldn’t be used, use user ids instead so you won’t have to change the whole code if someone changes their username, plus I don’t see the need to index players, and iterate through them in pairs, that reduces speed and the time taken for the function. On top of all that, you should use tables to set the ids instead of repeated code.

@Strongjohnfgamer you should use a code like this instead :
I tested my code, here is the output :

image

my code in server script service :

game.Players.PlayerAdded:Connect(function()

local BadgeService = game:GetService("BadgeService")

local BadgeID = 2124495817

local Developer_Ids = {
	
	123412323; --sample id for nanonauts
    991941211;
    451391631;--sample user id for strongjohnfgamer
          --remember to separate the values with ; in the array
	
}

    for _,player in ipairs(game:GetService("Players"):GetPlayers()) do
	      if table.find(Developer_Ids,player.UserId) then 
		   print("Developer" .. player.Name .. "Is in the game")
	   
	     for _,person in ipairs(game.Players:GetPlayers()) do
			 
			if not BadgeService:UserHasBadgeAsync(person.UserId, BadgeID) == false then
			      return
			 end
			  BadgeService:AwardBadge(person.userId, BadgeID)
			print(person.Name .. "Has received the badge")
	          end
 	            end
	             end
                   end)
No offence in any way is meant towards @CreditsMix , I only show that his provided code is not the best solution.

(post withdrawn by author, will be automatically deleted in 1 hour unless flagged)