Hello. I'm very new to Roblox game development and Lua in general, and have no idea how to go about this. (I've tried the documentation to no avail.)
I have buttons on a SurfaceGui that, when clicked, each fire a script with this block inside of them:
function leftClick() workspace.Music.OldTown:Play() end script.Parent.MouseButton1Click:Connect(leftClick)
(each button has a different song playing when clicked.)
Currently, the audio stacks when multiple buttons are pressed. I do not want this.
I want to try and make stopping the previous sounds seamless, i.e being able to click a button, play the song, and then if the player clicks another button for another song the previous song audio stops and the new audio starts playing without the need of a "stop all sounds" button that is separate from the regular buttons.
If you can help or need more details/code examples, please reply. Thanks.