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

Previous Thread :: Next Thread 
GreatOculus is not online. GreatOculus
Joined: 30 Aug 2009
Total Posts: 2103
03 Mar 2015 07:08 PM
I was wondering, how does math.random work, assuming you pass it only 1 value, instead of the usual 2?

i.e.
math.random(5)
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
03 Mar 2015 07:09 PM
Between 1 and the given argument.

That example is equivalent to math.random(1, 5)
Report Abuse
ChoongJae is not online. ChoongJae
Joined: 10 Oct 2009
Total Posts: 670
03 Mar 2015 07:10 PM
it automatically assumes the 1st argument as 1 in that situation
so

math.random(10) == math.random(1,10)
Report Abuse
GreatOculus is not online. GreatOculus
Joined: 30 Aug 2009
Total Posts: 2103
03 Mar 2015 07:11 PM
Thanks guys :)
Report Abuse
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
03 Mar 2015 07:14 PM
math.random(1,4)

4
2
1
3
4
2
1
3
4
2
1
3
-- It will print the same pattern, unless you do math.randomseed(tick())
Report Abuse
ForeverDev is not online. ForeverDev
Joined: 04 Oct 2008
Total Posts: 13300
03 Mar 2015 07:36 PM
math.random() returns a decimal between 0 and 1

math.random(n) returns an integer between 1 and n

math.random(n, x) return an integer between n and x
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