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
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
This discussion is preserved as it was. New answers, comments, and votes are closed.
22 comments
music plays for like 0.5 secs then stops o.o
worked in test but wouldnt switch to next song
now it works, I made a mistake. Sorry about that, it's because I woke up a few minutes ago, lol
Wait, again, doesn't work! Don't worry, I will fix it. Sorry about that
+1, for good Explanation!
Ok, I am testing it... Almost done! :)
thanks ~ !
Ok, so, ROBLOX's IsPlaying value for audios isn't working properly.. So I used the TimeLenght value to make the script wait
um.. its playing all the songs at once XD
Oh.. I am sorry, I will fix it
I think I found what I did wrong.. Lol
oh ok :3
Ok, so, I made a few changes and now it works in ROBLOX studio, now I will test it in an actual game to see if it works
is it working now ?
sorry for making you wait so much.. I had to debug it
Ok, I think I debugged it, it works on studio, so, I will test it on a game
This is strange.. It works well on ROBLOX studio but it doesn't work properly in games.. :( I will try..
like replay every few seconds then play all at once
Yeah! I don't know why that happens, the scrpt works properly at roblox studio. I am trying to fix it..
I gtg now, sorry :( Cya! I will try to fix it later.
oh ok
I am back. I am sorry but, I have to work on my project, do homework etc.. I can't debug this, but, I tried.