|
| 10 Jul 2015 12:52 AM |
okay I'm not sure what the problem here is,
So this is the code:
38: local players = game.Players:GetPlayers() 39: local ranPlayer = players[math.random(1,#players)]
This code works in the test world but not when I want to play it with my friends. (the 38 and 39 are line numbers not the code)
Why is this; the f9 console tells me this:
Workspace.Main:38: Bad Argument #2 random interval is empty
this is the one code that keeps my game running, and freezes it.
corrected from prev post :P |
|
|
| Report Abuse |
|
|
igunaa
|
  |
| Joined: 15 Sep 2010 |
| Total Posts: 2588 |
|
|
| 10 Jul 2015 12:57 AM |
Math.random gets from 0 to 1 right? I`m not sure, works like that on JavaScript tho.
Said the wise. |
|
|
| Report Abuse |
|
|
instawin
|
  |
| Joined: 04 Jun 2013 |
| Total Posts: 8777 |
|
|
| 10 Jul 2015 12:58 AM |
"Workspace.Main:38: Bad Argument #2 random interval is empty"
you get that error when your second argument to math.random is lower than your first argument
my bet is, that your script is running so fast, that a player hasn't joined the game yet. it then tries to pick a random player from none
if this is the case, this is what your line looks like then
local ranPlayer = players[math.random(1,0] |
|
|
| Report Abuse |
|
|
instawin
|
  |
| Joined: 04 Jun 2013 |
| Total Posts: 8777 |
|
|
| 10 Jul 2015 12:59 AM |
*local ranPlayer = players[math.random(1,0)]
l0l forgot a closing bracket |
|
|
| Report Abuse |
|
|
| |
|
|
| 10 Jul 2015 01:26 AM |
| just do like a repeat til' the NumPlayers is 1 or more |
|
|
| Report Abuse |
|
|
sparker22
|
  |
| Joined: 11 Mar 2010 |
| Total Posts: 846 |
|
|
| 10 Jul 2015 01:51 AM |
@igunna
math.random() takes 2 parameters. A min and max value. It grabs a random number between those 2 values. It does between 0 and 1 if no argument are passed. |
|
|
| Report Abuse |
|
|