I am working on making a tv show for my model TV in one of my games. What I want to do is that if you click the block again, it turns off the sound and when you click it, then it would play the sound again. I could not find any videos. Code is below.
Brick = script.Parent Sound = Brick.Show function onClicked() Sound:Play() end script.Parent.ClickDetector.MouseClick:connect(onClicked)
Here's my way to do this, as I don't like using functions that way
local sound = script.Parent.Show local a = 1 script.Parent.ClickDetector.MouseClick:Connect(function() if a == 1 then sound:Play() a = 2 elseif a== 2 then sound:Stop() a = 1 end end
local sound = script.Parent.Show local bool = false script.Parent.ClickDetector.MouseClick:Connect(function() bool = not bool if not bool then sound:Play() else sound:Stop() end end