#How would I make this ticking sound properly stop when a boolean value gets switched?

1 messages · Page 1 of 1 (latest)

mystic fulcrum
#

This code does play a sound, and it can stop when the boolean value turns true, but, as the boolean value is based on whether you're within a certain part or not, you can simply step outside of the part before the task.wait finishes and the sound will continue to play
How would I make it so that the value check ignores the wait command and stops the loop immediately? Is there a more efficient way to make my object play a sound once per second until a certain boolean is set to true?
(Note: I am not experienced in coding at all)

topaz karma
#

you could use getpropertychangedsignal to detect when isdetected changes, then maybe a task.spawn for the part where you play a sound and task.cancel for when they move out of the area