PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

PlayOnRemove

Sound

bool

When true, the Sound will play when it is removed from the game.

Note the sound will play when the Instance/Parent property of the Sound or one of its ancestors is set to nil. This means all of the following will cause the sound to play when PlayOnRemove is true. Note, this includes Instance/Destroy as the destroy function sets the parent to nil.

sound:Destroy()
sound.Parent = nil
sound.Parent.Parent = nil

Code Samples


Sound PlayOnRemove

In this sample a sound is created in the workspace, PlayOnRemove is set to true and the sound is then destroyed.

As Sound.PlayOnRemove is true, the sound will play when it is removed.

-- create a sound
local sound = Instance.new("Sound", game.Workspace)
sound.Name = "TestSound"
sound.SoundId = "rbxasset://sounds/uuhhh.mp3" -- oof

-- set PlayOnRemove to true
sound.PlayOnRemove = true

wait(3)
-- destroy the sound
sound:Destroy()