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: What is this sorcery!

Previous Thread :: Next Thread 
michaelh0042 is not online. michaelh0042
Joined: 23 May 2008
Total Posts: 1506
07 Jul 2014 12:33 AM
local part=Workspace.Color
function onTouch(Color)
script.Parent.BrickColor = BrickColor.new(math.random())
end
part.Touched:connect(onTouch)

Just noticed a bug or something. It only randomizes two colours (grey and white)
Pardon me if its obvious or something I haven't used Lua in 4 years.
Report Abuse
michaelh0042 is not online. michaelh0042
Joined: 23 May 2008
Total Posts: 1506
07 Jul 2014 12:34 AM
Hopefully my scripting isn't too rusty to the point where this is just a obvious mistake.
Report Abuse
Brickman2010 is not online. Brickman2010
Joined: 20 Nov 2009
Total Posts: 5547
07 Jul 2014 12:34 AM
if you want a random color, do

BrickColor.random()

instead. Colors have a number value, so it makes sense that the numbers within (0-1) are either white or grey.
Report Abuse
michaelh0042 is not online. michaelh0042
Joined: 23 May 2008
Total Posts: 1506
07 Jul 2014 12:36 AM
lol *facepalm* thanks
Report Abuse
blox6137 is not online. blox6137
Joined: 23 Nov 2008
Total Posts: 1109
07 Jul 2014 02:13 AM
If you want to use your original code, but have random colors, try this:

==

local part=Workspace.Color
function onTouch(Color)
script.Parent.BrickColor = BrickColor.new(math.random(), math.random(), math.random())
end
part.Touched:connect(onTouch)

==

System32? Delete it.
Report Abuse
blox6137 is not online. blox6137
Joined: 23 Nov 2008
Total Posts: 1109
07 Jul 2014 02:14 AM
You have to iterate the math.random a couple of times.

System32? Delete it.
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