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: Help with math.random()

Previous Thread :: Next Thread 
drslicendice is not online. drslicendice
Joined: 05 Mar 2011
Total Posts: 18737
27 Sep 2014 05:08 PM
Ello. I was wondering if a number would pick randomly 1-10. Since I want it to do it 2 times, how do I make it so it does not pick the same number?
Report Abuse
jode6543 is not online. jode6543
Joined: 16 Jun 2009
Total Posts: 5363
27 Sep 2014 05:09 PM
local x = math.random(1, 10)
local y
repeat
y = math.random(1, 10)
until x ~= y

~Jode
Report Abuse
BruceAB12 is not online. BruceAB12
Joined: 19 Jan 2012
Total Posts: 3238
27 Sep 2014 05:16 PM

math.randomseed(os.time());math.random(); math.random(); math.random() -- Because math.random() tends to produce equal sequences of numbers

a = math.random(1,10)

print(a) -- 5

b = math.random(1,10)

print(b) -- 2
Report Abuse
InternalSequence is not online. InternalSequence
Joined: 01 Nov 2012
Total Posts: 744
27 Sep 2014 05:35 PM
a=math.random(1,10)
b=math.random(1,10)
repeat b=math.random(1,10) until a ~= b

print('First number:'..tostring(a)..' Second number:'..tostring(b))
Report Abuse
TheAltOfDavid14 is not online. TheAltOfDavid14
Joined: 05 Feb 2014
Total Posts: 222
27 Sep 2014 05:37 PM
local a = math.random(10)
local b; repeat b = math.random(10) until b ~= a



-ForeverDev
Report Abuse
whyitmatters is not online. whyitmatters
Joined: 06 Apr 2013
Total Posts: 294
27 Sep 2014 05:50 PM
Why does i matter?
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