Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Script audio wont pause...?

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?

2 comments

0

make the pitch 0

0

But that wouldn't exactly 'Pause' it...

2 answers

✓ Accepted answer

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 comment

1

I was so going to say that ;)

This discussion is preserved as it was. New answers, comments, and votes are closed.