I tried using continue and break, but neither worked. I’m sure there’s a method to design a debounce system, but I can’t figure it out. the code im working on is a coded heart beat sound that plays when the player is in range and the volume changes depending on the players distance everything works well. here is the snippet
while task.wait(.1) do
if script.Enab.Value then
script.HrtBeat:Play() – this part
else
script.HrtBeat:Pause()
end
end
the heart beat sound doesn’t play as it should it gets harassed by the while loop i want it to just play the looped audio any help i don’t normally code with sounds so this is my weakness
while task.wait(.1) do
if script.Enab.Value then
script.HrtBeat:Play()
script.HrtBeat.Ended:Wait() -- add a event wait for sound to stop
else
script.HrtBeat:Pause()
end
end
Also use three backticks ``` to format your code. Like so
```
– paste your code here
while task.wait(.1) do
```
thanks I’ve never actually heard of .Ended before i will try using it in my code (edit)
works well but when the user leaves the area the sound still plays unlike before i’ll figure it out though