Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do you make this script loop?

I've been trying to make a looping music script, and this is what I've gotten so far in progress;

ID = '142463279' -- Set the ID to the music you want to play.
Looped = false -- Set to false if you want non-looped music.

Music=Instance.new("Sound" ,Workspace)
Music.Name = "Music"
if Looped == true then
Music.Looped = true
end
Music.SoundId = "http://roblox.com/asset/?id=142463279" 
Music:Play()

wait(120)
Game.Workspace.Music:remove()

ID = '142650764' -- Set the ID to the music you want to play.
Looped = false -- Set to false if you want non-looped music.

Music=Instance.new("Sound" ,Workspace)
Music.Name = "Music"
if Looped == true then
Music.Looped = true
end
Music.SoundId = "http://roblox.com/asset/?id=142650764" 
Music:Play()

wait(120)
Game.Workspace.Music:remove()

ID = '133217882' -- Set the ID to the music you want to play.
Looped = false -- Set to false if you want non-looped music.

Music=Instance.new("Sound" ,Workspace)
Music.Name = "Music"
if Looped == true then
Music.Looped = true
end
Music.SoundId = "http://roblox.com/asset/?id=133217882" 
Music:Play()

wait(120)
Game.Workspace.Music:remove()

ID = '170691997' -- Set the ID to the music you want to play.
Looped = false -- Set to false if you want non-looped music.

Music=Instance.new("Sound" ,Workspace)
Music.Name = "Music"
if Looped == true then
Music.Looped = true
end
Music.SoundId = "http://roblox.com/asset/?id=170691997" 
Music:Play()

1 answer

✓ Accepted answer

Instead of doing this 3 times, just use a while true do loop. This loop is infinite. When using a while true do loop, always remember to wait before ending it. Otherwise, studio will crash.

ID = "142463279"
Looped = false

while true do
	Music = Instance.new("Sound", workspace)
	Music.Name = "Music"
	if Looped == true then
		Music.Looped = true
		Music.SoundId = "http://roblox.com/asset/?id=142463279" 
		Music:Play()
	end
	wait(120)
	game.Workspace.Music:Destroy()
end

This discussion is preserved as it was. New answers, comments, and votes are closed.