I’m excited to announce some upcoming changes to the Sound object.
Sound.Playing
A new read/write value that will definitively tell whether the sound is playing or not.
This value is serialized, so it can be set in studio to create a background music or ambience scriptlessly.
This value is replicated, so for any Sound that has been in the workspace any changes will propagate to server and client.
This value will properly work on the server.
IsPaused/IsPlaying will be read-only getters of this value.
This value will bypass FilteringEnabled (this is current behaviour with play/pause/etc). This is used to create a local sound playback immediately that replicates.
Sound.TimePosition
This value now works properly on servers.
This value is now properly replicated among clients and server.
This value is now serialized, so it can be set in studio.
Sound.IsLoaded, Sound.Loaded
Two new properties to determine if the sound is loaded.
Sound.IsLoaded is a read-only boolean (true if loaded, else false)
Sound.Loaded is an event that will fire when the sound is loaded.
Sound.TimeLength
This value now works properly on servers.
This value will be 0 until the sound is loaded. It will not change if an invalid SoundId was set.
This value will be 0 immediately after setting SoundId.
Sound:Play(), Sound:Pause(), Sound:Resume(), Sound:Stop()
These methods will now behave consistently between server and client.
These methods will modify Sound.Playing and Sound.TimePosition.
Sound:Play() will first set the Sound.TimePosition to the last set Sound.TimePosition value (default 0), then set Sound.Playing to true.
Sound:Resume() will set Sound.Playing to true.
Sound:Pause() will set Sound.Playing to false.
Sound:Stop() will first set Sound.Playing to false, then set Sound.TimePosition to 0.
Sound.DidLoop, Sound.Ended, Sound.Paused, Sound.Played, Sound.Stopped
These events should now replicate and fire consistently across server and client.
Only the Play/Pause/Resume/Stop methods will trigger their respective events.
Sound.MinDistance, Sound.MaxDistance
Sound.MinDistance and Sound.MaxDistance will now work properly for “3D sounds” (sounds which are a direct child of a part).
Sound.MinDistance is the minimum distance at which a 3D sound will begin to attenuate. Think of it as the size of the object which is emitting the sound. An airplane would have a large Sound.MinDistance of 100, while a bee would have a small Sound.MinDistance of 0.1.
Sound.MaxDistance is the maximum distance at which a 3D sound can be heard. For 3D sounds outside of the Sound.MaxDistance range, no SoundChannel will be created for them. This value will also affect the 3D attenuation rate per distance.
These values are both still serialized (settable in studio) and replicated across server and client.
These changes should be completely backwards compatible with all existing Sound code.
If you think you do anything interesting/complex/hacky for sounds, I’d highly recommend testing that everything still works.
>>Test build link for dev forum members<<
The wiki will be updated with the new documentation, and expect these changes to be live within a few weeks.
Please let me know if you’ve got any questions or comments!