how to Stops the system when the specified value is reached (dynamic heartbeat system)

hello, I would like to do a dynamic heartbeat system with 3 levels, but the level has a specific configuration. When the specified value is reached, the widget will be displayed on the screen. And plays the sound of a heartbeat But I can’t make the sound stop when the main variable changes to the next level, causing the sound to play overlap. How can I stop playing when a specific value is changed?

example :
Power = 100 when i press shift Power will decrease
if Power = 60 will show HeartbeatLine green widget and play slow heartbeat sound
if Power = 40 will show HeartbeatLine yellow widget and play medium heartbeat sound
if Power = 20 will show HeartbeatLine red widget and play fast heartbeat sound
and when Power = 20 Players have to click the mouse to make the widgets and sound disappear

I am a new Thai game developer. And English is not my primary language I’m not sure if you guys will understand what I am communicating, if not, you can ask me more.


You need to spawn the sound and put the ref in a variable. Then you can stop it before playing the next sound: