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

How to isolate teams?

Asked by 10 years ago

Ok so me and my friends have been working on a huge holo script...

And this is what we got...

trainers =        {["Incrility"] = true;
                   ["GeniuseGeneral"] = true}

   local message = Instance.new("Message", game.workspace)
local player = game.Players:GetChildren()



game.Players.PlayerAdded:connect(function(player)
    if trainers[player.Name] then  
        player.Chatted:connect(function(msg)
            onChatted(msg)
             end)
             else

         end
    end)


 function onChatted(msg)
    if msg == "!setmode rcl" then
            message.Text = "Randomizing teams..."
            a = game.Players:GetChildren()
            for i,v in pairs(a) do
                if v.TeamColor~=BrickColor.new("White") then
                    v.TeamColor=BrickColor.new("White")
                end
            end 
            blueteam = 0
            redteam = 0
            me = false
                for i,v in pairs(a) do
                    if v.TeamColor == BrickColor.new("White") then
                        if blueteam <= redteam then   
                            v.TeamColor = BrickColor.new("Really blue")
                            blueteam = blueteam + 1   
                        else
                           v.TeamColor = BrickColor.new("Really red")
                            redteam = redteam + 1
                        end
                    elseif v.TeamColor == BrickColor.new("Really blue") then
                        blueteam = blueteam + 1
                    elseif v.TeamColor == BrickColor.new("Really red") then
                        redteam = redteam + 1
                    end
                    me=true

                    if me == true then Ready = true else Ready = false end
                        Run(Ready)
                        v:LoadCharacter(true)
                    end 
                    wait(2)
                    message.Text=""
                     elseif msg == "!end" then
                         a = game.Players:GetChildren()
                         pack=game.StarterPack:GetChildren()
                         if #pack>0 then
                             for i=1,#pack do
                                 pack[i]:destroy()
                             end
                         end
                         for i,v in pairs(a) do
                    if v.TeamColor==BrickColor.new("Really red") or v.TeamColor==BrickColor.new("Really blue") then
                v.TeamColor = BrickColor.new("White") 
                v:LoadCharacter(true)
            end
        end
    end
end


function Run(Ready) 

 local Weapons = {
 GPR = game.Lighting.Tools:FindFirstChild("GPR"),
 PSTL = game.Lighting.Tools:FindFirstChild("PSTL")}
 if Ready == true then
 Calling(Weapons)
  end
      end 


      function Calling(Weapons) 
          for k, v in pairs(Weapons) do 
          tool = v
          if tool ~= nil then
            tool:Clone().Parent = player.Backpack 
            tool:Clone().Parent = game.StarterPack
                 end                  
                        end

                        end

We tried to make it so that only teams red and blue get the weapons and only team white gets split into teams red and blue however it did not work... Could anyone please help us out... Thanks

Summary: This script was supposed to take all players from white team and place evenly into teams red and blue (withough affecting the playrs in team black or green) also when players are geared the weapons i want to make sure only red and blue teams get the weapons and not everyone... PLZ HELP!

0
That code has terrible formatting and I'm not really sure what it's doing since I can't read it. adark 5487 — 10y

Answer this question