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