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

Script audio wont pause...?

Asked by 8 years ago
script.Parent.ClickDetector.MouseClick:connect(function(a)
    script.Parent.Sound:Play()
    if script.Parent.Sound.IsPlaying == true then
        script.Parent.ClickDetector.MouseClick:connect(function(b)
            script.Parent.Sound:Pause()
        end)
    end
end)

I've even posted on the Forums! And that didnt even help. (Obviously) earlier i had a error but i fixed it but i dont know what im doing wrong to make it not pause...Help?

0
make the pitch 0 NotSoNorm 777 — 8y
0
But that wouldn't exactly 'Pause' it... zachattack220 25 — 8y

2 answers

Log in to vote
1
Answered by
funyun 958 Moderation Voter
8 years ago

Let's take a look at that script.

script.Parent.ClickDetector.MouseClick:connect(function(a) --Listener function 1.
    script.Parent.Sound:Play()
    if script.Parent.Sound.IsPlaying == true then
        script.Parent.ClickDetector.MouseClick:connect(function(b) --Listener function 2?
            script.Parent.Sound:Pause()
        end)
    end
end)

We can't have 2 functions listening on the same event. Instead, we'll have a conditional statement to control when the music gets paused, and when it gets unpaused.

script.Parent.ClickDetector.MouseClick:connect(function()
    if script.Parent.Sound.IsPlaying then --If we click while it's playing
        script.Parent.Sound:Pause() --Pause it
    else --If we click while it's not playing
        script.Parent.Sound:Resume() --Let it continue
    end
end)
1
I was so going to say that ;) duckyo01 120 — 8y
Ad
Log in to vote
0
Answered by 8 years ago
script.Parent.Sound:Stop() ---Can that be it?

Answer this question