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

How Do I make a Part to Make Audio Stop?

Asked by 9 years ago

I want to know how I make a part to make audio stop. I already have a part that makes audio play here are the two scripts I used:

1st script:

debounce = false

script.Parent.Touched:connect(function(hit)
if not debounce then
debounce = true
if(hit.Parent:FindFirstChild("Humanoid")~=nil)then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local Sound = script.Parent.Sound:Clone()
Sound.Parent = player.PlayerGui
Sound:Play()
wait(30)
end
debounce = false
end
end)

2nd script:

function ot(hit)
if hit.Parent ~= nil then
local player = game.Players:playerFromCharacter(hit.Parent)
if player ~= nil then
if player.leaderstats.Stage.Value == script.Parent.Name - 1 then
local h = hit.Parent:FindFirstChild("Humanoid")
if h ~= nil then
if h.Health ~= 0 then
player.leaderstats.Stage.Value = script.Parent.Name
end end end end end end

script.Parent.Touched:connect(ot)

2 answers

Log in to vote
0
Answered by
unmiss 337 Moderation Voter
9 years ago

I assume you're playing the sound for thirty seconds, then you want to stop it. If so, then Sound:Stop() should work. Here's an example:

local Sound = script.Parent.Sound:Clone()
Sound.Parent = player.PlayerGui
Sound:Play()
wait(30)
Sound:Stop()

Please comment if this is what you were looking for. Also, make sure this is in a LocalScript or it most likely won't work with your 'player' variable.

Ad
Log in to vote
-2
Answered by 9 years ago

Well, you need to just do Sound:Stop().

Answer this question