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 » Scripters
Home Search
 

Re: MATH.RANDOM PROBLEMS

Previous Thread :: Next Thread 
FactualTheory is not online. FactualTheory
Joined: 10 Sep 2013
Total Posts: 1365
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 is not online. 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 is not online. 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 is not online. 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
FactualTheory is not online. FactualTheory
Joined: 10 Sep 2013
Total Posts: 1365
10 Jul 2015 01:00 AM
thx :P
Report Abuse
systematicaddict is not online. systematicaddict
Joined: 13 Jul 2012
Total Posts: 4188
10 Jul 2015 01:26 AM
just do like a repeat til' the NumPlayers is 1 or more
Report Abuse
sparker22 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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