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: Pick randomely from table?

Previous Thread :: Next Thread 
sal212 is not online. sal212
Joined: 11 Apr 2010
Total Posts: 2929
07 Feb 2016 10:41 PM
How would you pick a random thing from my table?

local yellow3 = 255, 255, 255
local red3 = 255, 0, 0
local orange3 = 255, 106, 0
local black3 = 0, 0, 0
local ctable = {yellow3,red3,orange3,black3}


Report Abuse
LilMcManiac is online. LilMcManiac
Joined: 31 Oct 2011
Total Posts: 2812
07 Feb 2016 10:42 PM
local random = ctable[math.random(1,#ctable)]
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
07 Feb 2016 10:42 PM
local yellow3 = Color3.new(1, 1, 1)
local red3 = Color3.new(1, 0 ,0)
local orange3 = Color3.new(1, 106/255, 0)
local black3 = Color3.new(0, 0, 0)
local ctable = {yellow3,red3,orange3,black3}

local randomcol = ctable[math.random(#ctable)]
Report Abuse
sal212 is not online. sal212
Joined: 11 Apr 2010
Total Posts: 2929
07 Feb 2016 10:43 PM
ty


Report Abuse
gergy008 is not online. gergy008
Joined: 16 Mar 2008
Total Posts: 7039
07 Feb 2016 10:44 PM
Can I be that one guy to explain that there's no such thing as random? No? okay...


Play today! So much fun the more people that join: http://www.roblox.com/games/2047642/NEW-Build-A-Fortune-v0-9-6-Fixes
Report Abuse
sal212 is not online. sal212
Joined: 11 Apr 2010
Total Posts: 2929
07 Feb 2016 11:00 PM
Once I click a part and it chooses a random color, if I click it again, it would keep choosing the same color it first had when I clicked it first. For example, if I clicked it and it chose black, and keep clicking again, it will keep choosing black. Is this a problem on roblox's end?

local yellow3 = Color3.new(255, 255, 0)
local red3 = Color3.new(1, 0 ,0)
local orange3 = Color3.new(1, 106/255, 0)
local black3 = Color3.new(0, 0, 0)
local ctable = {yellow3,red3,orange3,black3}
local randomcol = ctable[math.random(#ctable)]
function Click()
game.Workspace.StairWalls.StairWall1.Smoke.Color = randomcol
wait(.2)
print(randomcol)
end

script.Parent.ClickDetector.MouseClick:connect(Click)


Report Abuse
gergy008 is not online. gergy008
Joined: 16 Mar 2008
Total Posts: 7039
07 Feb 2016 11:03 PM
try adding

#code print(math.random())

to your script and seeing if you get random numbers in output


Play today! So much fun the more people that join: http://www.roblox.com/games/2047642/NEW-Build-A-Fortune-v0-9-6-Fixes
Report Abuse
sal212 is not online. sal212
Joined: 11 Apr 2010
Total Posts: 2929
07 Feb 2016 11:06 PM
Its giving me different numbers


Report Abuse
gergy008 is not online. gergy008
Joined: 16 Mar 2008
Total Posts: 7039
07 Feb 2016 11:07 PM
Figured it out.

You're picking a colour, but never changing it

local yellow3 = Color3.new(255, 255, 0)
local red3 = Color3.new(1, 0 ,0)
local orange3 = Color3.new(1, 106/255, 0)
local black3 = Color3.new(0, 0, 0)
local ctable = {yellow3,red3,orange3,black3}
local randomcol = ctable[math.random(#ctable)]
function Click()
game.Workspace.StairWalls.StairWall1.Smoke.Color = randomcol
wait(.2)
print(randomcol)
end

script.Parent.ClickDetector.MouseClick:connect(Click)

should be

local yellow3 = Color3.new(255, 255, 0)
local red3 = Color3.new(1, 0 ,0)
local orange3 = Color3.new(1, 106/255, 0)
local black3 = Color3.new(0, 0, 0)
local ctable = {yellow3,red3,orange3,black3}
function Click()
game.Workspace.StairWalls.StairWall1.Smoke.Color = ctable[math.random(#ctable)]
wait(.2)
print(randomcol)
end

script.Parent.ClickDetector.MouseClick:connect(Click)


Play today! So much fun the more people that join: http://www.roblox.com/games/2047642/NEW-Build-A-Fortune-v0-9-6-Fixes
Report Abuse
sal212 is not online. sal212
Joined: 11 Apr 2010
Total Posts: 2929
07 Feb 2016 11:10 PM
thanks


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