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

making music switch when its not playing anymore?

How could i make this play another music after the one playing has stopped? Right now it only plays the same music again

local music = script:GetChildren()

while true do
	for i,v in pairs(music) do
		if v.Playing == false then
			repeat wait(1)
			v.Playing = true
			until v.Playing == false
		end
	end
end

2 comments

0

How muxh music do you have in the script, Number wise?

0

for now i have like 3 but i plan on adding more

1 answer

Your way of playing sounds is completely wrong.

To play a sound, call sound:Play()

This only needs to be done once and then lets you do whatever from then on.

If all you want to do is play music in a loop then wait until the Ended event is fired.

--Assuming sounds is already defined as an array/table of sounds

for _, s in sounds do
    s:Play()
    s.Ended:Wait() --Pauses execution until sound ends
end

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