|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 08 Sep 2013 07:40 PM |
how would I do that? If #teamlist > 1 then ...? |
|
|
| Report Abuse |
|
|
|
| 08 Sep 2013 07:41 PM |
| Replace the 1 with a 0 and there ya go |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 08 Sep 2013 07:44 PM |
It is working, thank you all.
|
|
|
| Report Abuse |
|
|