Example Attempt #1
while true do
wait()
if O.Value == true or O2.Value == true then
M:Play()
wait(M.TimeLength)
else
M:Stop()
end
end
I apologize for any lack of detail in my explanation. I've been scripting/coding/programming a sink (and other things) for several hours trying to intergrate different things and I'm a little worn.
My Problem
So what I'm working on right now is a sink, and while everything works completely fine I decided to add in a sound effect of running water. It works as I want it to like it is, but I realized if I were to turn off the sinks water the sound would play until the sound is completely done and then it stops ( and yes, I do know the reason behind that is because I have it wait the time of the sound, but this is the only example I could provide of what I've tried.) I have two variables, O and O2 that determine if either of the faucets are on, and when you click a button ( equivalent of turning sink knob ) the water runs and the sink is considered 'on.'
But what I can't seem to figure out is how would I stop the sound from playing instantly once both sinks are off( because the sound will still play as long as one is on as intended ).
Question
So in short, how would I stop the music/sound stop playing the minute both variable values == false? Am I even on the right track or is this a bad approach?
Thanks for the help!

6 comments
Puts me in the same hole. After I turn off both faucets the sound plays out until it's done then it stops. I'm trying to have it stop as soon as the condtions aren't met, which is when O and O2 = false. Maybe my sound is too long?
Oh, I see what the problem is
You’re :wait() line is yielding, making the code stop until it’s finished so it’ll never make it to the elseif statement
Try this?:
I edited my answer.
You genius. Thanks a lot.