Simple music script error

So i just made this script to repeat through some musics and it didn’t work. Fun fact: I never actually tried this before, usually i just use 1 music in my games so this might be a simple error.

game.SoundService.music1.Ended:Connect(function()
	script.Parent.music2:Play()
end)

game.SoundService.music2.Ended:Connect(function()
	script.Parent.music3:Play()
end)
	
game.SoundService.music3.Ended:Connect(function()
	script.Parent.music1:Play()
end)

Try using game:GetService(“SoundService”) instead of game.SoundService

Tried it out, it still doesnt work

There’s been some weird instances with SoundService not playing sounds that are replicated to the server, another alternate you could use is cloning the Sound and playing it that way instead? You got 2 choices here I’ll let you decide :thinking:

Simply put Sound:Play() at the start, That should work perfectly I think

The first music music1 already has the Playing property turned true.

I think the Playing property is read only/doesn’t replicate. Try using Sound:Play() to play the music. Sound | Roblox Creator Documentation

You are using script.Parent, Use SoundService.Sound, And parent the script to ServerScriptService

1 Like

I did both of that, and i don’t think it works still

Is it a Local Script or a Server script?

It is a serverscript, as it’s in serverscriptservice

local soundService = game:GetService("SoundService")

soundService.music1:Play()

soundService:WaitForChild("music1").Ended:Connect(function()
	soundService:WaitForChild("music2"):Play()
end)

soundService:WaitForChild("music2").Ended:Connect(function()
	soundService:WaitForChild("music3"):Play()
end)

soundService:WaitForChild("music3").Ended:Connect(function()
	soundService:WaitForChild("music1"):Play()
end)

still doesn’t work, only the first music plays

Is the sound looped? :thinking:

No, it ends and nothing else plays after that.

Just gonna put this here, attempting to play another sound after a sound has ended can result in some really weird Sound errors

1 Like

Even if i did make a new instance, after all the other songs end, what would i do

Try… Game.SoundService.Music1:play()

You could just wait until all of the other songs have ended, then destroy the instance afterwards & create a new song:

game.SoundService.music1.Ended:Connect(function()
    game.SoundService.music1:Destroy()

	local Sound = script.Parent.music2:Clone()
    Sound.Parent = script.Parent
    Sound.Play()
end)

game.SoundService.music2.Ended:Connect(function()
    game.SoundService.music2:Destroy()

	local Sound = script.Parent.music3:Clone()
    Sound.Parent = script.Parent
    Sound.Play()
end)
	
game.SoundService.music3.Ended:Connect(function()
    game.SoundService.music3:Destroy()

	local Sound = script.Parent.music1:Clone()
    Sound.Parent = script.Parent
    Sound.Play()
end)

This wouldn’t be the best approach to handle it, but it’s an alternate

1 Like

I tested the same script and it seems to work for me. Are you sure it’s not playing? try adding prints inside the functions.

1 Like