Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why music script stops working during middle of song?

Asked by
Hypgnosis 186
5 years ago

The first track value plays for about 30 seconds or so, and then it cuts out and doesn't continue. Any ideas on how to fix this?

Mainly looking at the while loop for the problem.

local songs = game.Workspace.trackList

local sound = Instance.new("Sound", songs)
sound.Name = "MusicPlayer"
sound.Volume = volume

local musicLength = songs.MusicPlayer.TimeLength

while true do
    for i = 1, #trackValues do
        sound.SoundId = trackValues[i]
        songs.MusicPlayer:Play()
        wait(musicLength)
        sound.MusicPlayer:Stop()
        wait(3)
    end
end
1
I noticed that at line 14 you did 'sound.MusicPlayer:Stop()' that can't be right, at line 12 you did songs.MusicPlayer as well so DaCrazyDev 444 — 5y
0
what exactly is "volume" greatneil80 2647 — 5y
0
local volume = 0.3 Hypgnosis 186 — 5y

Answer this question