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: using math.random for non-real numbers?

Previous Thread :: Next Thread 
Vyxium is not online. Vyxium
Joined: 31 Aug 2010
Total Posts: 1020
09 Jun 2014 11:43 PM
How can I use math.random for numbers with decimals like

position = math.random(1, 3)

and have it go to positions like 1.439 or 2.4083 and stuff like that.

Is that possible with math.random or would I have to use something else?
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
09 Jun 2014 11:46 PM
math.random() without any arguments, then just multiply that.
Report Abuse
Haschwalth is not online. Haschwalth
Joined: 30 Sep 2009
Total Posts: 24661
09 Jun 2014 11:46 PM
How about math.random() * math.random(1,3)
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
09 Jun 2014 11:47 PM
There really is no point in multiplying the random number by a random number, but you could do that.
Report Abuse
Kratos232 is not online. Kratos232
Joined: 28 Oct 2011
Total Posts: 229
09 Jun 2014 11:49 PM
By doing something like this:

local Number = math.random(10000, 30000) / 10000
You divide it to give decimals or it'd be giant.

or something like this:
local Number = math.random() * math.random(1, 3)

Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
09 Jun 2014 11:51 PM
Why are you guys multiplying it by a random integer...
Your 2 things do different things.

math.random() * 3

That isn't hard to do
Report Abuse
Vyxium is not online. Vyxium
Joined: 31 Aug 2010
Total Posts: 1020
09 Jun 2014 11:53 PM
Thanks all
Report Abuse
Kratos232 is not online. Kratos232
Joined: 28 Oct 2011
Total Posts: 229
09 Jun 2014 11:54 PM
Np. :)

~I like Toast~
Report Abuse
Haschwalth is not online. Haschwalth
Joined: 30 Sep 2009
Total Posts: 24661
10 Jun 2014 12:00 AM
@cant

eets 2 basik
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
10 Jun 2014 12:06 AM
And yours is not getting a random number between 0-3, more like between 0-1, 0-2, or 0-3
Report Abuse
Haschwalth is not online. Haschwalth
Joined: 30 Sep 2009
Total Posts: 24661
10 Jun 2014 12:24 AM
I know

:P
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