|
| 15 May 2015 10:16 AM |
| Say I have 4 sounds. How do I make a script play a random one and play a different one when it ends? |
|
|
| Report Abuse |
|
|
| |
|
|
| 15 May 2015 12:41 PM |
| HEEEEEEEEEEEEEEEEEEEEEEEELP |
|
|
| Report Abuse |
|
|
| |
|
|
| 15 May 2015 12:53 PM |
can you say something more than 1 word pls maybe teach me how to do that instead of saying what to use without any explanation |
|
|
| Report Abuse |
|
|
gIuton
|
  |
| Joined: 21 Apr 2015 |
| Total Posts: 102 |
|
|
| 15 May 2015 12:54 PM |
sounds = {sound1, sound1, sound3, sound4}
while true do --play sounds here end
Ey you like my sombrero? | rip hiddenreporter |
|
|
| Report Abuse |
|
|
instawin
|
  |
| Joined: 04 Jun 2013 |
| Total Posts: 8777 |
|
|
| 15 May 2015 01:15 PM |
local soundIDs = {1337, 9001, 300} local sound = Instance.new("Sound", game.Workspace") local intermissionTime = 10
while true do local ranSoundID = soundIDs[math.random(1, #soundIDs)] sound.SoundId = "rbxassetid://"..ranSoundID sound:Play() wait(sound.TimeLenght) sound.SoundId = "rbxassetid://" wait(intermissionTime) end |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 15 May 2015 01:15 PM |
| @instawin while wait() do* |
|
|
| Report Abuse |
|
|
instawin
|
  |
| Joined: 04 Jun 2013 |
| Total Posts: 8777 |
|
|
| 15 May 2015 01:16 PM |
made some typos
fix them yourself m8 |
|
|
| Report Abuse |
|
|
instawin
|
  |
| Joined: 04 Jun 2013 |
| Total Posts: 8777 |
|
|
| 15 May 2015 01:17 PM |
@time
no, my while loop doesn't need a wait() for the condition
it already has some waits in there already, it won't crash the game. |
|
|
| Report Abuse |
|
|
|
| 15 May 2015 01:18 PM |
@insta
Less lag, fixed some typos..
local soundIDs = {0000,0000,0000,0000} local Sound = Instance.new("Sound",workspace) local IntermissionTime = 10
for i = 1,math.huge do local ranSoundID = soundIDs[math.random(1, #soundIDs)] Sound.SoundId = "rbxassetid://"..ranSoundID Sound:Play() wait(Sound.TimeLength) Sound.SoundId = "rbxassetid://" wait(IntermissionTime) end |
|
|
| Report Abuse |
|
|
instawin
|
  |
| Joined: 04 Jun 2013 |
| Total Posts: 8777 |
|
|
| 15 May 2015 01:20 PM |
"for i = 1,math.huge do"
..
that's the exact same as an infinite while loop, and all you did was plop my script into it
it's the exact same thing as my while loop |
|
|
| Report Abuse |
|
|
|
| 15 May 2015 01:22 PM |
No its not.
i used workspace which is more efficient i fixed a few typos, find them yourself
I made some of the looks a bit better
also a numerical for loop is more efficient, too
read up, buddy. i tried to be nice. |
|
|
| Report Abuse |
|
|
instawin
|
  |
| Joined: 04 Jun 2013 |
| Total Posts: 8777 |
|
|
| 15 May 2015 01:28 PM |
"i used Workspace, more efficient"
true, but barely it's a trivial amount of time saved, barely noticeable
"numerical for loops are more efficient"
i'd like to know where you heard this
"fix your own typos"
he's lucky i even gave him a free script |
|
|
| Report Abuse |
|
|
| |
|
instawin
|
  |
| Joined: 04 Jun 2013 |
| Total Posts: 8777 |
|
|
| 15 May 2015 01:29 PM |
| "i'd like to know where you heard this" [2] |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 15 May 2015 01:32 PM |
| @insta while wait() do is proper noob. |
|
|
| Report Abuse |
|
|
instawin
|
  |
| Joined: 04 Jun 2013 |
| Total Posts: 8777 |
|
|
| 15 May 2015 01:33 PM |
@time
it's a thing of preference |
|
|
| Report Abuse |
|
|
|
| 15 May 2015 01:42 PM |
@insta
wow. quoting yourself to try to get noobs to agree.
You are a terrible scripter. |
|
|
| Report Abuse |
|
|
instawin
|
  |
| Joined: 04 Jun 2013 |
| Total Posts: 8777 |
|
|
| 15 May 2015 01:46 PM |
"wow. quoting yourself to try to get noobs to agree.
You are a terrible scripter."
lol wtf |
|
|
| Report Abuse |
|
|
Dr01d3k4
|
  |
| Joined: 11 Oct 2007 |
| Total Posts: 17916 |
|
|
| 15 May 2015 01:59 PM |
@TheNewChicken: while true do is better than for i = 1, math.huge
1) i will eventually overflow, and become math.huge, and math.huge == math.huge == true, so that loop isn't infinite 2) If you look at the bytecode (luac -l -p in terminal) http://pastebin.com/bEksayYD Lua knows while true is infinite, so can just jump back to the start, however it can't say that about for loops so has to keep evaluating the parameters.
|
|
|
| Report Abuse |
|
|
Intern33t
|
  |
| Joined: 19 Nov 2010 |
| Total Posts: 1530 |
|
|
| 15 May 2015 02:00 PM |
though i have to say i always rather use
for i = 1, math.huge do print(i) end
than
local i = 1 while wait() do i = i + 1 print(i) end |
|
|
| Report Abuse |
|
|
instawin
|
  |
| Joined: 04 Jun 2013 |
| Total Posts: 8777 |
|
|
| 15 May 2015 02:03 PM |
@droid
actually i do have a question
how long would it take for i to be equal to math.huge? |
|
|
| Report Abuse |
|
|
instawin
|
  |
| Joined: 04 Jun 2013 |
| Total Posts: 8777 |
|
|
| 15 May 2015 02:05 PM |
| actually i'll test that out right now |
|
|
| Report Abuse |
|
|
Dr01d3k4
|
  |
| Joined: 11 Oct 2007 |
| Total Posts: 17916 |
|
|
| 15 May 2015 02:07 PM |
| @insta: Hm idk. I'm not sure of the size of numbers Lua uses (i.e. 32 bit or 64 bit), and whether math.huge is just defined as 2^(32|64) and bigger. However I do know this happens - I once wrote a train system that used for i = 1, math.huge and after playing in the server for a while, the trains just stopped working. |
|
|
| Report Abuse |
|
|