Developer Joined Badge

Well you see, I scripted a code that is supposed to give people the Dev Joined badge, but it isn’t working for some reason.

local BadgeService = game:GetService("BadgeService")

local BadgeId = 2124884803
local CreatorName = {1034984688, 1034982532, 432660433}

game.Players.PlayerAdded:Connect(function(plr)
	for i, v in pairs(game.Players:GetPlayers()) do
		if table.find(CreatorName, v.UserId) then
			if not BadgeService:UserHasBadgeAsync(v.UserId, BadgeId) then
				BadgeService:AwardBadge(v.UserId, BadgeId)
			end
		end
	end
end)

I think your code only gives the badge to a person whose userid is in the CreatorName table.

This code should give the badge to any players who are in the game when a developer joins and to players who join while a developer is in the game.

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

local BadgeId = 2124884803
local Creators = {1034984688, 1034982532, 432660433}

local developersInGame = 0

local function giveCreatorBadge(plr)
	if not BadgeService:UserHasBadgeAsync(plr.UserId, BadgeId) then
		BadgeService:AwardBadge(plr.UserId, BadgeId)
	end
end

local function onPlayerAdded(newPlr)
	if table.find(Creators, newPlayer.UserId) then
		-- the player is a developer, give the badge to everyone in the server
		developersInGame += 1
		for _, plr in in ipairs(Players:GetPlayers()) do
			giveCreatorBadge(plr)
		end
	elseif developersInGame > 0 then
		-- There's a developer on the server, give the badge to this new player.
		giveCreatorBadge(newPlr)
	end
end

local function onPlayerLeave(leavingPlr)
	if table.find(Creators, leavingPlayer.UserId) then
		developersInGame -= 1
	end
end


Players.Playeradded:Connect(onPlayerAdded)
Players.PlayerRemoving:Connect(onPlayerLeave)

This code should give the badge to people who are in the server at the moment when the developer joins.

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

local BadgeId = 2124884803
local Creators = {1034984688, 1034982532, 432660433}

local function giveCreatorBadge(plr)
	if not BadgeService:UserHasBadgeAsync(plr.UserId, BadgeId) then
		BadgeService:AwardBadge(plr.UserId, BadgeId)
	end
end

local function onPlayerAdded(newPlr)
	if table.find(Creators, newPlayer.UserId) then
		-- the player is a developer, give the badge to everyone in the server
		for _, plr in in ipairs(Players:GetPlayers()) do
			giveCreatorBadge(plr)
		end
	end
end

Players.PlayerAdded:Connect(onPlayerAdded)
2 Likes