generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: HELP!!!

Previous Thread :: Next Thread 
TexasTech717 is not online. TexasTech717
Joined: 24 Apr 2012
Total Posts: 1129
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
TexasTech717 is not online. TexasTech717
Joined: 24 Apr 2012
Total Posts: 1129
26 Apr 2014 07:44 PM
Please somebody...
Report Abuse
TexasTech717 is not online. TexasTech717
Joined: 24 Apr 2012
Total Posts: 1129
26 Apr 2014 07:58 PM
;_;
Report Abuse
TexasTech717 is not online. TexasTech717
Joined: 24 Apr 2012
Total Posts: 1129
26 Apr 2014 08:27 PM
Bump
Report Abuse
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
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
TexasTech717 is not online. TexasTech717
Joined: 24 Apr 2012
Total Posts: 1129
26 Apr 2014 08:57 PM
Such logic...















Does not make sense....
Report Abuse
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image