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
 

math.random w/ text

Previous Thread :: Next Thread 
yankeejr is not online. yankeejr
Joined: 04 Jul 2012
Total Posts: 4906
13 Aug 2014 09:03 PM
why isn't this line working inside the script?

Order.Screen.SurfaceGui.LabelOne.Text = (math.random("test1", "test", "test3", "test4", "test6", "test7"))
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
13 Aug 2014 09:03 PM
tostring()
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
13 Aug 2014 09:04 PM
Because that's not how math.random works.

local texts = {"test1", "test", "test3", "test4", "test6", "test7"};

Order.Screen.SurfaceGui.LabelOne.Text = texts[math.random(#texts)]
Report Abuse
iiEssence is not online. iiEssence
Joined: 18 Jun 2014
Total Posts: 3467
13 Aug 2014 09:04 PM
hhuehuehue

k sorry

tests = {"test1", "test", "test3", "test4", "test6", "test7"}
Order.Screen.SurfaceGui.LabelOne.Text = tests[math.random(1,#tests)]
Report Abuse
Kingdaro557 is not online. Kingdaro557
Joined: 23 Mar 2008
Total Posts: 1439
13 Aug 2014 09:05 PM
That's not how the math.random function works. It can only use numbers, not a list of items. See: http://www.lua.org/manual/5.1/manual.html#pdf-math.random

To do what you want, you'd need to make a table first, then get a random indice of that table.

local options = {"test1", "test", "test3", "test4", "test6", "test7"}
Order.Screen.SurfaceGui.LabelOne.Text = options[math.random(1, #options)]
Report Abuse
Kingdaro557 is not online. Kingdaro557
Joined: 23 Mar 2008
Total Posts: 1439
13 Aug 2014 09:06 PM
These forums are incredibly fast, lol.
Report Abuse
yankeejr is not online. yankeejr
Joined: 04 Jul 2012
Total Posts: 4906
13 Aug 2014 09:09 PM
thanks!
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