How to locally play a sound when the player presses the gui button?

How to locally play a sound when the player presses the gui button?

I thought about placing already pre-adjusted sound in player gui and just play it, but is it safe? How do I make it play locally?

Just reference the sound inside SoundService if you want to locally play it, or you can use SoundService’s PlayLocalSound() function

--This should be a LocalScript
local Button = script.Parent
local Sound = game.SoundService:WaitForChild("SoundToPlay")


Thank you also I wanted to ask you, where should I place the sound or I have to create it through a script?

Sounds always play locally if you play them from a LocalScript. There’s only one exception where a LocalScript-played sound will not be strictly local in which all of the following must be true:

  • RespectFilteringEnabled must be off (you should never have it off to begin with)
  • The sound isn’t created by a LocalScript
  • The sound is located in a container that replicates to all clients

In this case, sound playback will replicate. Otherwise just use a LocalScript and you’re good.

1 Like

So if I make a local script and enable IsPlaying property of a sound which is already located in starter gui it will play locally?

IsPlaying is a read only property describing the playback state of the sound. Just call Play explicitly.

1 Like

You can use this method, but it does not work if you are trying to use SoundEffects with it


I personally have found it to be a lot more reliable than :Play(), but that is from personal experience

1 Like