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: random

Previous Thread :: Next Thread 
PraetorianTheGod is not online. PraetorianTheGod
Joined: 02 May 2014
Total Posts: 814
31 May 2017 07:39 PM
I want this to pick a random value from the table but I have no clue what I am doing
local FireSounds = {a=1,b=2}
local SoundGroup = FireSounds
local SoundNumber = math.random(1,#SoundGroup)
local Sound = SoundGroup[SoundNumber]
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
31 May 2017 07:40 PM
it will not work because it is a dictionary and dictionaries have 0 array length
Report Abuse
helperobc is not online. helperobc
Joined: 04 Sep 2012
Total Posts: 231
31 May 2017 07:41 PM
local THeFire = math.random(#FireSounds)
for i,v in pairs(FireSounds) do
if i == THeFire then
-- Do stuff
end
end


Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
31 May 2017 07:42 PM
um thats still wrong because there is no array part and thats just a dumber way to do ^
Report Abuse
Unsubtleties is not online. Unsubtleties
Joined: 28 Nov 2016
Total Posts: 9203
31 May 2017 07:42 PM
I just died inside.


Report Abuse
PraetorianTheGod is not online. PraetorianTheGod
Joined: 02 May 2014
Total Posts: 814
31 May 2017 07:43 PM
thanks
Report Abuse
PraetorianTheGod is not online. PraetorianTheGod
Joined: 02 May 2014
Total Posts: 814
31 May 2017 07:43 PM
figured it out im dumb
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
31 May 2017 07:45 PM
if ur trying to do something like pick a random sound id

local sounds = {
id,
id,
id,
id,
id,
id...
}

local randomSound = sounds[ math.random(#sounds) ]
print(randomSound)
Report Abuse
PraetorianTheGod is not online. PraetorianTheGod
Joined: 02 May 2014
Total Posts: 814
31 May 2017 07:46 PM
yeah I got what you meant when I made it into a dictionary my bad I am bad at this
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