all music playing at the same time.... i want it to play then play next random song once the other finishes
while true do wait(0) script:FindFirstChild("Music"..math.random(1,4)):Play() end
Firstly, lets rename the script with a new name (e.g. MUSICPLAYER) So, lets say you have 4 different audios which are all located in game.Workspace.MUSICPLAYER
Here is what you need to write to make it work: (it is tested, it works and it is random(whereas math.random is not very random))
Note: I am still working on it.....
wait(10) --waiting for the assets to load properly music = script:GetChildren() a = true while a == true do wait(1) a = false for i,v in pairs(music) do math.randomseed(tick()*math.random()) local MusicRandom = music[math.random(1,#music)] MusicRandom:Play() wait(4) repeat wait() until MusicRandom.TimePosition == 0 if MusicRandom.TimePosition == 0 then wait(1.5) a = true end end end
You are not checking if the song has finished before playing the next sound. Click here for sound api
You need to check the sound using this Click here
This script just shows you how it works, it is untested as I don't have the time atm.
local soundName = "" while true do wait(0.5) if not script.soundName.IsPlaying then soundName ="Music"..math.random(1,4) local sound = script:FindFirstChild(soundName) sound:Play() end end