SoundEnded

Constructor:

SoundEnded()

Description

This event is triggered when the audio object is stopped or when it finishes playing.

Examples

Create an Audiosource player. Assign the audio path to the player to play. Stop playing the current audio after 2 seconds. Observe whether the event is triggered or not.

function SoundEndedEvent() -- define the method when the audio is stopped
    print("The event of pausing or stopping playing is triggered")
end
local AS = RWObject.Create("AudioSource") -- create a player
AS.PlayOnAwake =false
AS.AudioClip = "rwid://L1vtZTBThT1RCvBVdK"  -- assign a path
AS.SoundEnded:Connect(SoundEndedEvent) -- register the event that the audio is stopped
AS:Play() -- play the audio
wait(2) -- wait 2
AS:Stop() -- stop the audio