SoundPlayback
This was deprecated in v1.0.0
A handle to one sound started by SoundPool:PlaySound. It wraps the
borrowed Sound instance, lets you pause / resume / stop it or change its config while it
plays, and returns the pooled part to the pool with Return. When the sound ends on its own
(Sound.Ended) it is returned automatically. After Return, using the handle in any way
errors with "Sound has already been returned.".
local playback = pool:PlaySound(1234567890)
playback:UpdateConfig({ Volume = 0.3, Position = character.HumanoidRootPart.Position })
playback.Ended:Connect(function()
print("done") -- the pooled sound has already been returned at this point
end)
task.wait(1)
playback:Stop()
playback:Return() -- Stop does not fire Ended, so return it yourself
This package is no longer maintained; see the deprecation notice on SoundPool.
Properties
Trove
SoundPlayback.Trove: TroveHolds the wrapped signals below. It is not cleaned by Return; clean it yourself if you keep the handle around.
SoundInstance
This item is read only and cannot be modified. Read OnlySoundPlayback.SoundInstance: SoundThe pooled Sound that is playing. Read its properties (e.g. TimePosition) here; prefer UpdateConfig for writing.
PooledSound
This item is read only and cannot be modified. Read OnlySoundPlayback.PooledSound: PooledSoundThe borrowed Part the Sound is parented to; move it to move the sound in 3D.
Returned
This item is read only and cannot be modified. Read OnlySoundPlayback.Returned: booleantrue once the pooled sound has been given back to the pool.
Ended
This item is read only and cannot be modified. Read OnlySoundPlayback.Ended: Signal<string>Wraps Sound.Ended: fires with the sound id when playback finishes naturally. The pool has already returned the sound when your connection runs.
Stopped
This item is read only and cannot be modified. Read OnlySoundPlayback.Stopped: Signal<string>Wraps Sound.Stopped: fires with the sound id after Stop.
Paused
This item is read only and cannot be modified. Read OnlySoundPlayback.Paused: Signal<string>Wraps Sound.Paused: fires with the sound id after Pause.
Resumed
This item is read only and cannot be modified. Read OnlySoundPlayback.Resumed: Signal<string>Wraps Sound.Resumed: fires with the sound id after Resume.
DidLoop
This item is read only and cannot be modified. Read OnlySoundPlayback.DidLoop: Signal<string,number>Wraps Sound.DidLoop: fires with the sound id and the loop count each time a looped sound restarts.
Functions
UpdateConfig
Applies the fields set in soundConfig to the playing Sound (and Position to the pooled
Part) immediately. Fields left nil are not touched. This is currently the only way to
configure a sound, since PlaySound ignores its config argument.
Pause
SoundPlayback:Pause() → ()Pauses the Sound (Sound:Pause()), keeping its TimePosition. Fires Paused.
Resume
SoundPlayback:Resume() → ()Resumes a paused Sound from where it stopped (Sound:Resume()). Fires Resumed.
Stop
SoundPlayback:Stop() → ()
Stops the Sound (Sound:Stop()) and resets its TimePosition. Fires Stopped, not Ended,
so the pooled sound is not returned automatically; call Return when you are done with it.
Return
SoundPlayback:Return() → ()
Gives the pooled Part back to the SoundPool so it can be reused, and marks the handle as
returned. It does not stop the Sound first, so call Stop before Return if it is still
playing. Called automatically when the sound Ended. After this, indexing the handle (any
property or method) errors, so drop your reference.
Errors
| Type | Description |
|---|---|
| "Sound has already been returned." | Called a second time on the same playback. |