New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Still have questions? Join our Discord server and get real time help.
Log in to vote

How do I stop all other audio in the game and play the audio selected by the player?

Asked by 5 months ago

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()


(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.

Wherever you're putting your sounds, you want to destroy the one that currently exists and replace it with a new sound with the ID the player requested to play. BashCaster 2670 — 5mo

Answer this question