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

How do you make a brick stop playing the sound when you click it again?

Asked by 3 years ago

function onclicked() script.Parent.ClickDetector.MaxActivationDistance = 0 script.Parent.ClickSound.Playing = true wait(6) script.Parent.ClickDetector.MaxActivationDistance = 32 end script.Parent.ClickDetector.MouseClick:Connect(onclicked) i want to make it so if you click on the button it changes colour to red and starts playing a sound if you click again it stops playing the sound and changes back to green need this for a game i want to make thanks

0
so you basically need when a sound is playing, the brick turns red and when a song stops, the brick turns to green? Extremliyas 15 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

here is the script for it since i'm too lazy to explain.

script.Parent.ClickDetector.MouseClick:Connect(function()
    if script.Parent.Airhorn.Playing == false then
        script.Parent.ClickDetector.MaxActivationDistance = 0 
        script.Parent.Airhorn.Playing = true 
        script.Parent.BrickColor = BrickColor.new("Bright red")
        wait(6) 
        script.Parent.ClickDetector.MaxActivationDistance = 32 
    elseif script.Parent.Airhorn.Playing == true then
        script.Parent.ClickDetector.MaxActivationDistance = 32 
        script.Parent.Airhorn.Playing = false 
        script.Parent.BrickColor = BrickColor.new("Bright green")
    end 
end)
0
BTW REPLACE THE AIRHORN WITH THE SOUND NAME!!!!!!!!!! Extremliyas 15 — 3y
Ad

Answer this question