So, I am trying to make a random music script and after a few tweaks it seems to randomize, however it is not playing afterwards and I could not think of why this is happening and i'm very confused. Help would be greatly appreciated <3 also it is a Script not a local script

while true do
	wait()
	if game.Workspace.mus1.IsPlaying == true then
		
	else
		ID = math.random(1,3)
		if ID == 1 then 
			game.Workspace.MusicID.Value = 303226835
			end
			
		if ID == 2 then
			game.Workspace.MusicID.Value = 504618717
		end
		
		
		if ID == 3 then
			game.Workspace.MusicID.Value = 411822352
			
			
		end	
		workspace.mus1.SoundId = workspace.MusicID.Value
		wait(1)
		script.Parent:Play()
	end	
	end
	


4 comments

0

"== true then else", why not use "== false then"

0

Why not use a table containing all your sound Id's and use SoundId = table[math.random(1,#table)]? Also you could use the Song.Ended event to start the next song rather than using an endless loop.

0

If you'd like I could write up an example.

0

Please, if it does not bother you ! :D