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: Random Sounds Script Plays All Sounds

Previous Thread :: Next Thread 
Faxu is not online. Faxu
Joined: 08 Feb 2010
Total Posts: 2937
08 Jun 2014 02:08 AM
Why does this script cause both sounds to play? The only reason I can think of for this is if I did the math.random wrong, but I can't figure out what it is.



_G.song = 1

while true do
wait(5)
if _G.song == 1 then
sndid = (math.random(1,2))
if sndid == 1 then
script.Parent.one:Play()
elseif sndid == 2 then
script.Parent.two:Play()
else print("math.random did not create a valid sound ID")
wait(120)
end
end
end
Report Abuse
sonicdiablo is not online. sonicdiablo
Joined: 05 Feb 2009
Total Posts: 1661
08 Jun 2014 02:17 AM
It never does the wait(120)
Report Abuse
Faxu is not online. Faxu
Joined: 08 Feb 2010
Total Posts: 2937
08 Jun 2014 02:19 AM
Oh, I just realized this, although I'm not sure how I can fix this. Help?
Report Abuse
Faxu is not online. Faxu
Joined: 08 Feb 2010
Total Posts: 2937
08 Jun 2014 02:20 AM
Never mind, I can just put a wait after every else.
Report Abuse
sonicdiablo is not online. sonicdiablo
Joined: 05 Feb 2009
Total Posts: 1661
08 Jun 2014 02:21 AM
Move one or more end(s).
Report Abuse
Faxu is not online. Faxu
Joined: 08 Feb 2010
Total Posts: 2937
08 Jun 2014 02:23 AM
Alright, I added a bunch of waits where appropriate and it's working quite perfectly now! 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