What would I want to achieve?
My problem is pretty simple, I am working on a background music player for my fighting game that just randomly picks a song and plays it, so far so good, the game starts and the first music plays, however when the first music is finished, the player just stops, no second music begins to play even tho the script obviously is meant to play it.
My Coding
local songs = {game.SoundService.Music1, game.SoundService.Music2, game.SoundService.Music3, game.SoundService.Music4, game.SoundService.Music5, game.SoundService.Music6, game.SoundService.Music7, game.SoundService.Music8, game.SoundService.Music9, game.SoundService.Music10, game.SoundService.Music11, game.SoundService.Music12, game.SoundService.Music13, game.SoundService.Music14, game.SoundService.Music15, game.SoundService.Music16}
local last_Song
local function pickSong()
local pickedSong = math.random(1, #songs)
return songs[pickedSong]
end
while true do
function songDecider()
local song = pickSong()
if song ~= last_Song then
song:Play()
game.SoundService.CurrentMusic.Value = song
last_Song = song
song.Ended:Wait()
else
songDecider()
end
end
songDecider()
end
Now this is probably a bit messy because I got a little angry and tried recoding it quickly, but only to find out no good result, anyways did I miss something into this code that only makes it run once, I tried checking and CurrentMusic.Value appears to change, but the music just doesn’t start playing, would I be missing something incredibly stupid?