Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

making music switch when its not playing anymore?

Asked by
Paldi 109
7 years ago
Edited 7 years ago

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
0
How muxh music do you have in the script, Number wise? TayLife12 69 — 7y
0
for now i have like 3 but i plan on adding more Paldi 109 — 7y

1 answer

Log in to vote
0
Answered by
P100D 590 Moderation Voter
7 years ago
Edited 7 years ago

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
Ad

Answer this question