Sound.Volume=0/0 results in nan value and total game sound mute

Dividing a positive number by 0 and storing that value into a sound’s Volume property results in the value being set to 1.
Dividing a negative number by 0 and storing that value into a sound’s Volume property results in the value being set to 0.
Dividing 0 by 0 and storing that value into a sound’s Volume property results in the value being set to ‘nan’, and every sound in the game being muted.

I think the desired behavior of setting to 0/0 would be to set the volume to 0 and not mute all sounds globally.

To reproduce, insert this script code into a blank place: Sound Volume 0/0 'nan' Value Repro Script - Pastebin.com

Notes:
The global mute does not happen unless the sound with volume of ‘nan’ is currently being played and it does not happen if the sound with volume of ‘nan’ does not have a valid SoundId.

1 Like

But why are you dividing by 0 anyway?

Nice to know I can block all sound using Volume = 0/0 though. huehuehue

I was trying to be lazy with some local sound volume changer thing. A local script would multiply a sound’s volume by something like 0.7 to put it at 70% maximum volume. To change to another percentage you’d have to divide it by the same one first to get it back to its original base volume, and then you could divide it by a different number. What I didn’t foresee when I wrote that piece of code is that if you set the local volume to 0 and then tried to change to something else, you’d end up dividing 0 by 0.

Now I just keep track of what the base volume is and there’s no problems.

I think I have discovered the same issue with setting a very large number in Pitch.
In my case, I use speed as a parameter for calculating a sound’s pitch, but I managed to glitch the physics engine, flinging the part into infinity which created infinite speed, completely breaks the audio engine (Note: for all clients as well!) as it was entered into the pitch variable.

I can mitigate the issue in my game by clamping the speed parameter, but I think staff should look into this issue anyway as any exploiter can basically mute an entire game by simply setting Pitch/Volume of a sound to infinity.

Taking a look.

A similar things happens with workspace.Gravity except setting that to 0/0 shuts down the server.