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: Random "Table Print" (HELP PLEASE!)

Previous Thread :: Next Thread 
FoggedOut is not online. FoggedOut
Joined: 09 Dec 2011
Total Posts: 3021
05 Aug 2013 05:19 PM
I'm new to... Well, nothing, BUT I have forgotten a lot since I got off Roblox for a week. I need help make the table say something random each time I would run this script. If you look below, you will see the 3 Numbers I will be using, the Table{}, and the Print(). I don't know how to make the print random!

local myArray = {"1", "2", "3"}
local myEmptyArray = {}

wait(5)

print(myArray[math.random]) <---
print(myArray[math.random]) <---
print(myArray[math.random]) <---
Report Abuse
BlueTaslem is not online. BlueTaslem
Joined: 11 May 2008
Total Posts: 11060
05 Aug 2013 05:21 PM
You want to pick a random index, which is a number, the result of math.random:

myArray[math.random(1,#myArray)] --pick a random number from 1 to array length
Report Abuse
mylifeis2cooldlol is not online. mylifeis2cooldlol
Joined: 08 Mar 2011
Total Posts: 874
05 Aug 2013 05:22 PM
Sooo close too1!!

math.random(min,max)

--if neither min or max is passed, it will return a float between 0 - 1

--if the max is passed, it will do 1-max

--if both are passed, it will do between min-max
Report Abuse
FoggedOut is not online. FoggedOut
Joined: 09 Dec 2011
Total Posts: 3021
05 Aug 2013 05:23 PM
Oops, I probably shouldn't have put in Numbers, and a math.random to confuse people.... Here, this may help:

local myArray = {"HI THERE", "I'M IN SECOND SLOT!", "Lolwat"}
local myEmptyArray = {}

wait(5)

print(myArray[math.random]) <---
print(myArray[math.random]) <---
print(myArray[math.random]) <---
Report Abuse
mylifeis2cooldlol is not online. mylifeis2cooldlol
Joined: 08 Mar 2011
Total Posts: 874
05 Aug 2013 05:23 PM
Still...doesn't....change...anything....
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