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

.IsPlaying issue. Any way to fix?

Asked by 10 years ago

I have ran into an issue with audio and I'm wondering if there is any way around it. I want it so that whenever a song is finished playing another song will begin playing. The problem is that after one song runs, about 90% of the time a second song will not play. I am not quite sure why but I believe that the problem lies with .IsPlaying. I read that it doesn't work and even when it does it still isn't working too well. Is there any way to deal with the audio problem without having the script just wait for the length of the song that is playing?

songs = {142401311, 163870179, 149761849}

workspace.Music:Play() --this is one method that I read to fix it, it doesn't quite help
wait(0.5)
workspace.Music:Pause()
wait(0.5)
workspace.Music:Stop()

while wait() do
    if workspace.Music.IsPlaying == false then
        selection = math.random(1, #songs)
        workspace.Music.SoundId = "http://www.roblox.com/asset/?ID="..songs[selection]
        if selection == 1 then
            workspace.Music.Pitch = .53
        elseif selection == 2 then
            workspace.Music.Pitch = .75
        elseif selection == 3 then
            workspace.Music.Pitch = .5
        end
        workspace.Music:Play()
    end
end
0
You may want to look into the new Sound properties: TimeLength and TimePosition. http://wiki.roblox.com/index.php?title=API:Class/Sound Spongocardo 1991 — 10y
1
I already know about the new sound properties but I think they aren't quite working yet. They don't do anything at the moment. FearMeIAmLag 1161 — 10y
0
Ah right. Spongocardo 1991 — 10y

1 answer

Log in to vote
0
Answered by 10 years ago
songs = {142401311, 163870179, 149761849}

workspace.Music:Play() --this is one method that I read to fix it, it doesn't quite help
wait(0.5)
workspace.Music:Pause()
wait(0.5)
workspace.Music:Stop()

function Pitch() -- Methods help you at all moments! ;)
selection = math.random(1, #songs)
        workspace.Music.SoundId = "http://www.roblox.com/asset/?ID="..songs[selection]
        if selection == 1 then
            workspace.Music.Pitch = .53
        elseif selection == 2 then
            workspace.Music.Pitch = .75
        elseif selection == 3 then
            workspace.Music.Pitch = .5
        end
end

while true do
    if workspace.Music.IsPlaying == false then
        Pitch()
        workspace.Music:Play() -- What i noticed is that you don't have a pause and you have a If statement blocking because it only works if IsPlaying... When the song stops it doesn't run.
--Logical problems :/
    elseif workspace.Music.IsPaused == true then -- Alternate method
        Pitch()
        workspace.Music:Play()
    end
    --wait(workspace.Music.TimeLength * 1000) -- Until song ends
    wait(120)
end

Hope this helps! If not tell output! ~marcoantoniosantos3

1
Since TimeLength isn't working yet it is set as 0 so you'd practically be doing wait(0) FearMeIAmLag 1161 — 10y
0
k then change it to wait(120), ty :3 marcoantoniosantos3 200 — 10y
Ad

Answer this question