So I made my own custom music player script that is suppose to play a random song from a list after the first song ends, however what ends up happening is it'll play one song, then about 2 seconds or so later it'll start another song and keep going. Eventually it's playing all the possible songs at once. I used a ServerScript that runs a loop inside a spawnbox model.
songs = {222607140, 221660385, 149318510, 163357343, 148620885} sound = script.Sound while true do rsong = math.random(1#,songs) song = songs[rsong] sound2 = sound:clone().Parent = script.Parent sound2.SoundId = ("rbxassetid://"..song) wait(sound2.TimeLength) sound:Destroy() end
You're not stopping the sound before you destroy it. Try using sound:Pause() or sound:Stop() before killing it.
songs = {222607140, 221660385, 149318510, 163357343, 148620885} sound = script.Sound while true do rsong = math.random(1#,songs) song = songs[rsong] sound2 = sound:clone().Parent = script.Parent sound2.SoundId = ("rbxassetid://"..song) wait(sound2.TimeLength) sound:Stop() sound:Destroy() end