grunt1994
|
  |
| Joined: 04 Oct 2008 |
| Total Posts: 1201 |
|
|
| 01 Jul 2016 11:05 AM |
How would i go around making a radio in the workplace that plays 4 different songs on loop without crashing the game... Each song plays about 2 mins |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 01 Jul 2016 11:29 AM |
Songs = {1234,4312,5123,6512} -- replace with your IDs sound = Instance.new("Sound",workspace) sound.Looped = false sound.Volume = 1
while true do for i,songId in pairs(Songs) do sound.SoundId = "rbxassetid://"..songId repeat wait() until sound.TimeLength > 0 sound:Play() wait(sound.TimeLength) sound:Stop() sound.SoundId = "" repeat wait() until sound.timeLength < 0 wait(1) -- the gap between songs if you want one end end
-- So in this script I do some repeat wait()s just to make sure that we are waiting the proper duration between songs. Often I have changed the Id and the TimeLength changed after a brief delay - this will ensure that doesn't happen. ALTERNATIVELY if you know that it's going to wait for exactly 120 seconds, you can just say
Songs = {1234,4312,5123,6512} -- replace with your IDs sound = Instance.new("Sound",workspace) sound.Looped = false sound.Volume = 1
while true do for i,songId in pairs(Songs) do sound.SoundId = "rbxassetid://"..songId sound:Play() wait(120) -- assuming they are all exactly 2 minutes sound:Stop() wait(1) -- gap between songs end end
|
|
|
| Report Abuse |
|
|
grunt1994
|
  |
| Joined: 04 Oct 2008 |
| Total Posts: 1201 |
|
| |
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 01 Jul 2016 12:16 PM |
Yeah I messed up in the top one:
Songs = {1234,4312,5123,6512} -- replace with your IDs sound = Instance.new("Sound",workspace) sound.Looped = false sound.Volume = 1
while true do for i,songId in pairs(Songs) do sound.SoundId = "rbxassetid://"..songId repeat wait() until sound.TimeLength > 0 sound:Play() wait(sound.TimeLength) sound:Stop() sound.SoundId = "" repeat wait() until sound.TimeLength == 0 wait(1) -- the gap between songs if you want one end
|
|
|
| Report Abuse |
|
|