|
| 27 Feb 2015 12:06 PM |
function PlaySound() ChosenSoundId = SoundIds[math.random(1,#SoundIds)] if ChosenSoundId ~= LastChosenSoundId then LastChosenSoundId = ChosenSoundId Sound.SoundId = "http://www.roblox.com/asset/?id="..ChosenSoundId Sound:Play() wait(Sound.TimeLength) Sound:Stop() PlaySound() else PlaySound() end end
Sound is the Sound Instance in workspace. SoundIds is a table enholding all Ids, why doesn't it work? It does not output anything and works fine in Solo. |
|
|
| Report Abuse |
|
|
|
| 27 Feb 2015 12:12 PM |
Idk the problem, but this is easier to type and maybe more efficient. Also, use local variables.
local LastChosenSoundId function PlaySound() local ChosenSoundId = SoundIds[math.random(1,#SoundIds)] if ChosenSoundId ~= LastChosenSoundId then LastChosenSoundId = ChosenSoundId Sound.SoundId = "http://www.roblox.com/asset/?id="..ChosenSoundId Sound:Play() wait(Sound.TimeLength) Sound:Stop() end PlaySound() end
Use basic debugging stuff. Try printing TimeLength in online play, see if that works. Also, make sure you give time for the sound to load in Online play, because the assets DO take time to load. |
|
|
| Report Abuse |
|
|
|
| 27 Feb 2015 12:48 PM |
Am already preloading it, owing to my console it seems it loops the function, I added some prints and my console gets spammed quickly.
|
|
|
| Report Abuse |
|
|
|
| 27 Feb 2015 12:51 PM |
| Printing TimeLength prints zero all the time ;_; |
|
|
| Report Abuse |
|
|
|
| 27 Feb 2015 12:54 PM |
| If it is going over and over too fast, check what I told you about the SoundLength. It apparently doesn't work online, as I thought. |
|
|
| Report Abuse |
|
|
|
| 27 Feb 2015 12:56 PM |
I done what you said, and it printed "0".
Well how will I then detect if it stopped? Dx |
|
|
| Report Abuse |
|
|
|
| 27 Feb 2015 01:15 PM |
Just added a wait(120) in between, the best option I think. |
|
|
| Report Abuse |
|
|
|
| 27 Feb 2015 01:19 PM |
| Played one sound, then stopped doing things. |
|
|
| Report Abuse |
|
|