How can i create music zones with multiple songs per area

How would i create different music areas (player inside a part hears music) that has multiple songs inside ONE AREA.

Specifically, how would I have the player cycle through the music after staying in ONE area.

use tables. literally just use tables

local zones = {
zone1 = {
4587349583495, --random numbers i spammed my keyboard but these would be song ids
4347556478356387465,
2345834579345,
},
zone2 = {
3473298457345346,
543534534634,
}
}

each time zone is changed just start cycling through a different table with a for loop and play that song. make sure to stop the ones from the other zone use like sound.stopped or whatever i forgot wjhat the event is called but then just when the event is activated cal a function that will start the next in the “playlist”

2 Likes

Hey lulwut leader, for what you’re trying to do
you can create a table consisting of sound you wanna play
and use an amazing module made by foreverhd called ZonePlus

(or just use Touch, region3, raycast, whatever)

and just loop through the table and play the sounds

if you just want a table of id’s you can do

local table= {
    1,
    2,
}
local part = script.Parent -- path to area

part.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
         for i, v in pairs(table) do
            local  sound = Instance.new("Sound", part)
            sound.SoundId = v
            sound.Looped = true -- change dis if u want
            sound:Play()
        end
    end
end)
part.TouchEnded:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        for i, v in pairs(part:GetChildren()) do
            if v:IsA("Sound") then
                v:Destroy
            end
        end
    end
end)

now i have to mention that using Touch is not the best idea, that’s why i mention ZonePlus in the beginning

(i can still improve the code but i’ll leave that up to you)