Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

[EASY!] Why does it only give the player the badge if the first name joins and not the others?

So I want it to give the player a badge if any of the three plays join the game. How do I make it cuz right now it only works if the first player "Obbytasticc" joins

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

game.Players.PlayerAdded:Connect(function(Player)
	if game.Players:FindFirstChild("ObbyTasticc" or "Denxly" or "Unaffectedgaming") then
		for i, Plr in pairs(game.Players:GetPlayers()) do
			BadgeService:AwardBadge(Plr.userId, BadgeID)
		end
	end
end)

2 answers

Try:

local BadgeService = game:GetService("BadgeService")
local BadgeID = 2124568651
local Admins = {"ObbyTasticc", "Denxly", "Unaffectedgaming"}

game.Players.PlayerAdded:Connect(function(Player)
	for Index, Admin in pairs(Admins) do
		if game.Players:FindFirstChild(Admin) then
			for i, Plr in pairs(game.Players:GetPlayers()) do
				BadgeService:AwardBadge(Plr.userId, BadgeID)
		        end
		end
	end
end)

edit: game:GetService("Players") should be used in place of game.Players

Try this:

local BadgeService = game:GetService("BadgeService")
local BadgeID = 2124568651
local AllowedPlayers = {111744534,405136096,928878533} -- 111744534 = ObbyTasticc, 405136096 = Denxly, 928878533 = Unaffectedgaming

game.Players.PlayerAdded:Connect(function(Player)
    if table.find(AllowedPlayers,Player.UserId) then -- Check if the player is in the Allowed Table
       BadgeService:AwardBadge(Player.UserId, BadgeID)
    end
end)

1 comment

0

I think he means if an admin joins, (in this case ObbyTasticc, Denxly, and Unaffectedgaming), then all players in their server will get a badge.

This discussion is preserved as it was. New answers, comments, and votes are closed.