Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 3 years ago

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

Log in to vote
2
Answered by 3 years ago
Edited 2 years ago

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

Ad
Log in to vote
0
Answered by 3 years ago

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)
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. User#30567 0 — 3y

Answer this question