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 
Aj7Fish is not online. Aj7Fish
Joined: 30 Dec 2014
Total Posts: 500
22 Feb 2015 04:40 PM
Is it possible to pick a specific random color for a part so;


script.Parent.BrickColor = BrickColor.new(math.random("Really red") or ("Really black"))
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
22 Feb 2015 04:41 PM
No, so just get a random element from a table containing the colors you want.
Report Abuse
OtheusPompeiusMagnus is not online. OtheusPompeiusMagnus
Joined: 27 Aug 2008
Total Posts: 1300
22 Feb 2015 04:56 PM
script.Parent.BrickColor = BrickColor.new(math.random()<.5 and "Really red" or "Really black")
Report Abuse
Stefan631 is not online. Stefan631
Joined: 23 Dec 2010
Total Posts: 1350
22 Feb 2015 05:17 PM
local colors = {BrickColor.new('Really red'); BrickColor.new('Really black')};

script.Parent.BrickColor = colors[math.random(1, #colors)];
Report Abuse
thedestroyer115 is not online. thedestroyer115
Joined: 19 Dec 2010
Total Posts: 11546
22 Feb 2015 05:19 PM
@Stefan
you don't need semicolons.
+ you need to use commas in your table.


local Colors = {
BrickColor.new("Black"),
BrickColor.new("White")
}

Object.BrickColor = Colors[math.random(1, #Colors)]
Report Abuse
Stefan631 is not online. Stefan631
Joined: 23 Dec 2010
Total Posts: 1350
22 Feb 2015 05:25 PM
The semicolons substitute commas in tables.
Report Abuse
thedestroyer115 is not online. thedestroyer115
Joined: 19 Dec 2010
Total Posts: 11546
22 Feb 2015 05:32 PM
Correct, however everyone uses commas.

I don't mean to offend your coding style, but it might confuse beginners.
Report Abuse
thedestroyer115 is not online. thedestroyer115
Joined: 19 Dec 2010
Total Posts: 11546
22 Feb 2015 05:32 PM
(and by everyone I mean most people)
Report Abuse
Stefan631 is not online. Stefan631
Joined: 23 Dec 2010
Total Posts: 1350
23 Feb 2015 06:36 AM
One of the best coders here, cntkillme, uses semicolons.

Your move.
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
23 Feb 2015 06:50 AM
You're a wannabe.

Your move.
Report Abuse
Stefan631 is not online. Stefan631
Joined: 23 Dec 2010
Total Posts: 1350
23 Feb 2015 06:51 AM
True true, but what does that make you?
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
23 Feb 2015 06:52 AM
It makes me Skye.
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
23 Feb 2015 06:53 AM
"True true, but what does that make you?"

you must be new here
Report Abuse
Stefan631 is not online. Stefan631
Joined: 23 Dec 2010
Total Posts: 1350
23 Feb 2015 06:53 AM
I can call you wannabe Skye.
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
23 Feb 2015 06:53 AM
Using; semicolons in scripts; is really dumb; they should only; be used in language; that;s just my opinion; though;
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
23 Feb 2015 06:55 AM
Lol jk. But don't offend eLunate, she is the new queen of the Scripters forum, by unanimous election.
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
23 Feb 2015 06:55 AM
"that;s"

Jarod, I swear...
Report Abuse
Stefan631 is not online. Stefan631
Joined: 23 Dec 2010
Total Posts: 1350
23 Feb 2015 06:56 AM
She usurped it from dr0id3k4. :)
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
23 Feb 2015 06:58 AM
Ne
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
23 Feb 2015 06:59 AM
Pretty much, and people have remarked at how similar she acts to Dr01d3k4. But idk about that, I didn't know Dr01d3k4.
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
23 Feb 2015 07:15 AM
Also usurped is a very fancy word I had to Google it and even managed to spell usurp wrong.
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
23 Feb 2015 08:56 AM
"No, so just get a random element from a table containing the colors you want.|


"script.Parent.BrickColor = BrickColor.new(math.random()<.5 and "Really red" or "Really black")"

"local colors = {BrickColor.new('Really red'); BrickColor.new('Really black')};"


"local Colors = {
BrickColor.new("Black"),
BrickColor.new("White")
}

Object.BrickColor = Colors[math.random(1, #Colors)]"


No, you're all scripting wannabes.


script.Parent.BrickColor = BrickColor.random()


Your move :D
Report Abuse
LucasLua is not online. LucasLua
Joined: 18 Jun 2008
Total Posts: 7386
23 Feb 2015 09:50 AM
lol'ed
Report Abuse
Aalok is not online. Aalok
Joined: 20 Jun 2014
Total Posts: 1136
23 Feb 2015 09:53 AM
colors={BrickColor.new(0);BrickColor.new(255)} part.BrickColor=colors[math.random(1,#colors)]
Report Abuse
Dr01d3k4 is not online. Dr01d3k4
Joined: 11 Oct 2007
Total Posts: 17916
23 Feb 2015 09:56 AM
"She usurped it from dr0id3k4. :)"
wat
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