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
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: How would I pick a random number from an array?

Previous Thread :: Next Thread 
Chockytash is not online. Chockytash
Joined: 18 Nov 2011
Total Posts: 11
02 Jan 2015 06:35 PM

function Chooser()
local numlist = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,13,24,25,26}
-on this line i need to somehow pick a random number from that array/\

wait(6)
end

Chooser()

anyone know how to?

Report Abuse
Funse is not online. Funse
Joined: 11 Jun 2012
Total Posts: 7887
02 Jan 2015 06:35 PM
math.random(1,26)
Report Abuse
Tripane is not online. Tripane
Joined: 03 Jun 2011
Total Posts: 11432
02 Jan 2015 06:36 PM
I just found out about this a minute ago, lol

local choice = numlist[math.random(1, #numlist)]
print(choice)
Report Abuse
vividtrip is not online. vividtrip
Joined: 14 Oct 2008
Total Posts: 2890
02 Jan 2015 06:36 PM
If you want to generate a random number, use math.random(minValue, maxValue). If you want to pick a value from the array then use numlist[math.random(1, #numlist)].
Report Abuse
BenAboom is not online. BenAboom
Joined: 17 Nov 2011
Total Posts: 44
02 Jan 2015 06:38 PM
no that would not work because i want to remove some of those numbers later on the script, which cant be done with that. i said FROM THE ARRAY NOT WITH A NEW RANDOM VARIABLE

READ BEFORE YOU WRITE NOOB
Report Abuse
Tripane is not online. Tripane
Joined: 03 Jun 2011
Total Posts: 11432
02 Jan 2015 06:39 PM
that better be an alt

and you asked to take a random number from the table, and that's it
Report Abuse
BenAboom is not online. BenAboom
Joined: 17 Nov 2011
Total Posts: 44
02 Jan 2015 06:41 PM
i was referring to the first guy not you (second) btw. "reply" just puts my post to the bottom. you helped a lot, thanks.
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
02 Jan 2015 06:41 PM
Well the array is numbers from 1 to 26 so

math.random(1, 26)


If you want it from the table

local tab = {"omg one", "two", "yo", "sup"}

print(tab[math.random(1, #tab)])
Report Abuse
vividtrip is not online. vividtrip
Joined: 14 Oct 2008
Total Posts: 2890
02 Jan 2015 06:42 PM
If that is an alt, then I'm more disturbed by the fact that one of them is female and the other male.
Report Abuse
BenAboom is not online. BenAboom
Joined: 17 Nov 2011
Total Posts: 44
02 Jan 2015 06:45 PM
it was my sisters, i logged onto mine to check if my buy order has gone through and i didnt log back in
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