Hello, I am trying to make a script that shuffles songs randomly. My issue is that it only plays one song then stops. Thanks in advance.
Songs = game.SoundService.Music:GetChildren() while true do ChosenSong = Songs[math.random(1,#Songs)] print(ChosenSong.Name) ChosenSong:Play() ChosenSong.Ended:Wait() wait(15) end
I figured it out! The script needed to be a local script in the player. I also made the variables local and added a SoundService variable. Here's the updated script:
local SoundService = game:GetService("SoundService") local Songs = SoundService:WaitForChild("Music"):GetChildren() game.Players.LocalPlayer.CharacterAppearanceLoaded:Wait() while true do local ChosenSong = Songs[math.random(1,#Songs)] ChosenSong:Play() ChosenSong.Ended:Wait() end