How would I play a sound only for the local player?

So, I have audio for my loading screen and I would like it to play only for the local player, so for your player. Say someone else joins the game, I would like it to restart the song for them and just play it for them yet the other player is on a different part of the song.

3 Likes

You want the LocalScript to execute the playing of the sound, rather than allowing the sound to play continuously. It’s fairly simple.

I have the sound playing by default and then disables when the user press’s play.

Image:

Do not allow the sound to be automatically playing. Use the advantage of the global scope and play the sound as the script is loaded, not in the event. The event will stop the sound.

You can just use the ThemeIntoSong:Play() method at the start of the script, and keep the sound not playing at the start and just let the local script start it when they join.

Like this?

Image:

1 Like

You could use SoundService:PlayLocalSound().

Would I use ThemeIntroSong:PlayLocalSound()?

That doesn’t make a difference because if the SoundService respects filtering enabled, which is on by default and recommended, a client toggling sound won’t affect other clients. Do not toggle that for the reasons of exploits regarding sound spam.

You should only have to use the :Play() method if you are using a localscript.
The code you showed above should work for you.