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 :))
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.