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

Team Change Admin Commands?

Asked by 9 years ago

I have players in both teams Red and Blue and i want that when i say "!end" all players be moved back into team white. Those are the colors not the names BTW... Name for team white is actually Trainee.

function End(msg)
    if msg == "!end" then
        a = game.Players:GetChildren()
            for i,v in pairs(a) do
                if v.TeamColor==BrickColor.new("Really Red") or v.TeamColor==BrickColor.new("ReallyBlue") then
    v.TeamColor = BrickColor.new("White")
    end
end
    end
end

How do i fix this plz hlep

1 answer

Log in to vote
0
Answered by
M39a9am3R 3210 Moderation Voter Community Moderator
9 years ago

ReallyBlue and Really Red do not exist, Lua is a case sensitive scripting language. There is a "Really blue" and "Really red" however.

It also does not appear there is a connection line, so you will want to add that.

function End(msg)
    if msg == "!end" then
        a = game.Players:GetChildren()
            for i,v in pairs(a) do
                if v.TeamColor==BrickColor.new("Really red") or v.TeamColor==BrickColor.new("Really blue") then --Lua IS CASE SENSITIVE! SPELLING MATTERS!
    v.TeamColor = BrickColor.new("White")
      end
    end
    end
end
game.Players.PlayerAdded:connect(function(plr) plr.Chatted:connect(End) end) --Connection line, connects to the player, then it connects to whatever the player chats.
Ad

Answer this question