|
| 26 Apr 2014 06:30 PM |
I'm trying to put everything that's in a group in 'Active' in Lighting into teams evenly, however, it only does a few before skipping ahead to the function "CheckForEven." How do I make it so that it does all 12?
function AddTeams() Team1 = Instance.new("ObjectValue") Team1.Name = "Team1" Team1.Parent = game.Lighting Team2 = Instance.new("ObjectValue") Team2.Name = "Team2" Team2.Parent = game.Lighting Team1Count =0 Team2Count =0 local c = game.Lighting.Active:GetChildren() for num, obj in pairs(c) do team = math.random(1,2) if team == 1 then obj:clone().Parent = game.Lighting.Team1 Team1Count = Team1Count + 1 elseif team == 2 then obj:clone().Parent = game.Lighting.Team2 Team2Count = Team2Count + 1 CheckForEven() end end end
function CheckForEven() wait(1) if Team1Count < Team2Count then local Children1 = game.Lighting.Team2 local Children2 = game.Lighting.Team1 Children1:Destroy() Children2:Destroy() AddTeams() elseif Team2Count < Team1Count then local Children1 = game.Lighting.Team2 local Children2 = game.Lighting.Team1 Children1:Destroy() Children2:Destroy() wait(3) AddTeams() end end |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
|
| 26 Apr 2014 08:34 PM |
local Items={}--Put the stuff you want to split here local Teams={{},{}}--And they will appear here
local Team=math.random(#Teams) while #Items>0 do table.insert(Teams[Team],table.remove(Items,math.random(#Items))) Team=Team%#Teams+1 end |
|
|
| Report Abuse |
|
|
|
| 26 Apr 2014 08:57 PM |
Such logic...
Does not make sense.... |
|
|
| Report Abuse |
|
|
|
| 26 Apr 2014 09:07 PM |
You could to local Items=game.Lighting.Active:GetChildren() instead of {}, then run through each team and parent the thing to wherever you wanted it to go. |
|
|
| Report Abuse |
|
|