✓ Accepted answer
Alright! I'll help you out.
What you need to do is create a new variable called toggled and set it to false.
Brick = script.Parent
Sound = Brick.Sound
Toggled = false
function onClicked()
Sound:Play()
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
After that, we need to check whether the music is playing, let's do it by checking if the variable is true or false!
Brick = script.Parent
Sound = Brick.Sound
Toggled = false
function onClicked()
if Toggled == false then
Toggled = true
Sound:Play()
else
Toggled = false
Sound:Stop()
end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
Explanation:
The toggled variable is set to either true or false so that the script can see if the audio is playing. You could also check the .IsPlaying property, however, in this example I used a variable.
Hope I helped you out!
4 comments
lol I have mine with just a line difference. (no flex)
yes, but i posted an explanation and tried to explain the script, you can tell the guy is new. and you just spedran that script like ur sonic, no offense, but i think if u answer u should give an explanation to the asker
Thanks for the help guys!
Sorry, that's just how I am and just hungry for reps. That's all. LOL im a true gangsta