so im making an asym game where different music plays all the time but i want it so that when one song starts all the other songs mute until the song ends, or smth like a layer’d music system where each song is given a layer and when its playing any songs under its layer are muted, say a chase theme with layer 2 starts, the bg theme with layer 1 mutes.
You could try making it so it sets the volume to 0 and setting it to the amount you want depending of the layer. I did this for one of my asym games.
Just set volume to 0 to the other songs and the playing one gets it’s volume higher
how would i check which layer songs are playing?
You would make lists of all this stuff so you know by what song is playing what layer it is and every other song. From a client script you can check if a song is playing with song.Playing ..
That will be true of false.
For this, group all the songs into a Folder named MusicFolder (or anything else, but then you have to change the name) and put this script in the instance that also has the new Folder as a child.
It should look like this
Instance
|_ this script
|_ MusicFolder
|_ your songs
Here is the script you can try using:
local musicFolder = script.Parent.MusicFolder -- if you need you can change the hierarchy
local songs = musicFolder:GetChildren()
local songLayers = {}
for _, song in ipairs(songs) do
if song:IsA("Sound") then
songLayers[song] = song:GetAttribute("Layer") or 1
end
end
-- Function to play a song and mute lower layers
local function playSongWithLayer(song)
local currentLayer = songLayers[song]
for otherSong, layer in pairs(songLayers) do
if otherSong ~= song and layer < currentLayer then
otherSong.Volume = 0
end
end
song:Play()
song.Ended:Wait()
for otherSong, layer in pairs(songLayers) do
if layer < currentLayer then
otherSong.Volume = 1
end
end
end