Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make a sound stop in a plugin?

Asked by 4 years ago

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

0
help meeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee BongoCatJoosan 77 — 4y

1 answer

Log in to vote
0
Answered by
Roger111 347 Moderation Voter
4 years ago

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.

Ad

Answer this question