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
 

Radio with multiple songs

Previous Thread :: Next Thread 
grunt1994 is not online. 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 is online. 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 is not online. grunt1994
Joined: 04 Oct 2008
Total Posts: 1201
01 Jul 2016 12:00 PM
Awesome, Thanks :)
Report Abuse
Soybeen is online. 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
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