I’m currently tying to play multiple music and i added a button to play and stop the music if the player wishes it. I’m stuck on a specific problem and it should be an easy solution. how do I call out base on its Sound class and not the name of the sound file because all my sound has the name of the song which I intent to keep.
script.Parent.Script.Sound:Play()
You would run through a loop of all the songs and find the ID of the correct song, then play that song.
local songs = where the parent sound is located
for I, v in pairs (songs:GetChildren()) do
v:Play()
end)
2 Likes
Maybe you could have your script update a single Sound instance with the soundID of the current song that’s playing. How are you changing the song now? Do you have a separate Sound instance for each song and cycle through those? Even if you’d rather keep them organized that way you could cycle through them and copy the id from the ‘current’ song to the single Sound instance, so you always have the current song in one place(in the workspace or explorer or wherever you store them)
modification of what @Generated_Scrxpt said:
local MasterSound = script.Parent.Sound --or whatever you name it in the explorer
for I, v in pairs (songs:GetChildren()) do
MasterSound.SoundId = v.SoundId
MasterSound:Play()
MasterSound.Ended:Wait() --yield script until the song is finished, then move on to the next....
end)
disclaimer: possible pseudo code, not tested, just an idea
1 Like
Song has to be the part of the song, example a part is in workspace so the parent is workspace, just a note.
Right a folder or grouped model containing the songs thats named: songs
In my game I just use a list of soundid’s in the script and cycle through those.
1 Like