Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

1 comment

0

so you basically need when a sound is playing, the brick turns red and when a song stops, the brick turns to green?

1 answer

✓ Accepted answer

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)

1 comment

0

BTW REPLACE THE AIRHORN WITH THE SOUND NAME!!!!!!!!!!

This discussion is preserved as it was. New answers, comments, and votes are closed.