So, I have a list of songs, and when you click on their button, their respecting song plays. How can I use a stop button to stop audio from playing WITHOUT wasting tons of code space?
function onButtonClicked()
script.Parent.Parent.Audio1:Stop()
script.Parent.Parent.Status.Text = "Stopped"
end
script.Parent.MouseButton1Click:connect(onButtonClicked)
You can ignore the text part. As you can see, I only have one audio, but once the library becomes bigger...
function onButtonClicked()
script.Parent.Parent.Audio1:Stop()
script.Parent.Parent.Audio2:Stop()
script.Parent.Parent.Audio3:Stop()
-- AND SO ON...
script.Parent.Parent.Status.Text = "Stopped"
end
script.Parent.MouseButton1Click:connect(onButtonClicked)
How can I achieve this same effect without wasting code space? If there is an alternate way to stop the audio currently playing, please tell me. Thanks!

2 comments
Thanks! Also, a follow-up question: how can I make it so that people would have to stop the song (via the Stop button) before playing another song (via clicking a song button)?
Nevermind, I figured it out.