Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to make a sound stop in a plugin?

So I'm making a plugin that allows sound to be played. But the problem is how do I stop it?

game:GetService("SoundService"):PlayLocalSound(song)

Someone please help, I'll mark you as answer if you can figure it out :))

1 comment

0

help meeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee

1 answer

Answer:

local function playLocalSound(soundId)
	-- Create a sound
	local sound = Instance.new("Sound")
	sound.SoundId = soundIdHere
	-- Play the sound locally
	SoundService:PlayLocalSound(sound)
	-- Once the sound has finished, destroy it
	sound.Ended:Wait()
	sound:Destroy()
end

Note: You don't have to wait for the sound to end, you can destroy it whenever you would like.

This discussion is preserved as it was. New answers, comments, and votes are closed.