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
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Not sure how to go about this.

Previous Thread :: Next Thread 
bellyboy99 is not online. bellyboy99
Joined: 27 Jan 2010
Total Posts: 433
08 Sep 2013 07:28 PM
teamlist = game.Workspace.Teams:GetChildren()
BlackTeam = teamlist[math.random(1,#teamlist)] -- argument 2 is empty

--How would I make sure that their is a team in teamlist? Currently, if there is none it breaks.
Report Abuse
tehtochcoph is not online. tehtochcoph
Joined: 18 Jul 2013
Total Posts: 193
08 Sep 2013 07:33 PM
TL = game.Workspace.Teams
teamlist = TL:GetChildren()
if TL:findFirstChild("BlackTeam") then
BlackTeam = teamlist[math.random(1,#teamlist)] -- argument 2 is empty
end

--You know you want me, you know i want you --
Report Abuse
crazyman32 is online. crazyman32
Joined: 13 Apr 2008
Total Posts: 18027
08 Sep 2013 07:35 PM
If math.random's second argument is less than the first, you get that error.

Check to make sure that 'teamlist' has a value greater than 0 before runing the assignment to BlackTeam w/ the math.random function.
Report Abuse
bellyboy99 is not online. bellyboy99
Joined: 27 Jan 2010
Total Posts: 433
08 Sep 2013 07:39 PM
BlackTeam is not a child of TL. BlackTeam is a variable assigned to player created teams located in TL... The names of the teams are at player discretion.
Report Abuse
bellyboy99 is not online. bellyboy99
Joined: 27 Jan 2010
Total Posts: 433
08 Sep 2013 07:40 PM
how would I do that?
If #teamlist > 1 then
...?
Report Abuse
crazyman32 is online. crazyman32
Joined: 13 Apr 2008
Total Posts: 18027
08 Sep 2013 07:41 PM
Replace the 1 with a 0 and there ya go
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
08 Sep 2013 07:43 PM
^ Genius. The thing is that there is no 0th array inside the table.
Report Abuse
bellyboy99 is not online. bellyboy99
Joined: 27 Jan 2010
Total Posts: 433
08 Sep 2013 07:44 PM
It is working, thank you all.

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