Hello! I was trying to create a local music system the other day, and I was successful. Well, for the most part. Every now and then, 2 songs play at once. I don’t know why this is; the code looks perfectly fine to me. I was hoping someone could help me out!
I have a folder in ReplicatedStorage that contains all of the sounds which are to be played by this LocalScript in StarterGui:
local MusicFolder = game.ReplicatedStorage:WaitForChild("Music") -- music folder
local AvailableMusic = MusicFolder:GetChildren() -- the sounds
while true do
local randomTrack = AvailableMusic[math.random(1, #AvailableMusic)] -- gets a random sound
wait(2) -- delay before next song plays
randomTrack:Play() -- plays the selected sound
wait(randomTrack.TimeLength) -- waits for the sound to end (by waiting its TimeLength)
end
It works fine most of the time, as I said. I just need some quick help to debug it. Thanks!
If you forgot the issue, it was that sometimes 2 songs would play at once.