PcoWSkbVqDnWTu_dm2ix
Collapse Sidebar

MaxDistance

Sound

float

The maximum distance a client’s listener can be from the Sound's origin and still hear it. Only applies to Sounds parented to a Part or Attachment (3D sounds).

How MaxDistance impacts the attenuation of a sound (manner in which it fades out) is dependent on the Sound/RollOffMode property. When Sound/RollOffMode is set to use an inverse type distance model (Inverse or InverseTapered) the MaxDistance will not effect the attenuation of the sound. This means that low values for MaxDistance will cause the sound to abruptly cut off when the listener reaches the MaxDistance. In most cases this is not desirable and developers are advised not to use low MaxDistance values.

When Sound/RollOffMode is set to a linear type distance model (Linear or LinearSquared) the sound will attenuate between Sound/EmitterSize and MaxDistance (with playback volume reaching zero at MaxDistance). This is less realistic, but in some cases allows attenuation to be handled in a more intuitive way.


Code Samples


Sound MaxDistance

This sample includes a brief demonstration of how Sound.MaxDistance works.

A Part is instanced in the Workspace with a looped Sound playing within it. A function is made to listen to the Sound’s MaxDistance and change the size of a sphere whenever it changes. The sphere’s radius will always be equal to the Sound’s MaxDistance.

This example helps demonstrate how the sound is only audible when the client’s listener (by default the Camera’s position) is within the sphere.