I have recently tried to work on the sounds of my game and one of the problems I am facing is that even when there is only 1 instance of a sound in the game the audio duplicates to both the server and the player and plays twice.
I had searched about this problem on the forms and one of the solutions I got was to tick the Playing property to false and enable the sound through a local script with the following.
script.Parent:Play() -- The sound starts as soon as the player joins
But then the other problem I have started to face is that when I try to pause the music from another script, it stops the sound from playing on the local server but the sound on the server keeps playing.
the sound turning off on local is probably because you used a local script, there’s not much information here, what script did you use to play the sound and where did you put it
Local Scripts are only parented for Clients to be used.
If you’re trying to understand how to mute the server itself you can use Remote-Events.
Although I do recommend if you want an easier way, please let the Client play the Music, Server Music when trying to be muted only will work for the client and not the Server. Client’s are more reduced to using anything server sided without a proper function call from a Remote or Firing a Remote Event.
I have an area through which players can listen to the songs they want withought changing songs for everyone else in the game. So it is important for the music to be played client sided.
Interesting, so you’re trying to detect those in a box with sound, which means you need a Local Script to detect the Client thats in a ‘region’ with different audio to play from being in the Box?
Not exactly, Basically each player has a sound instance with them which should be controlled locally. Its not dependent on any region, Its the player’s choice to listen to what they want, but withought changing the sound for everyone. The part about changing the song into a new one works perfectly fine, but because the sound instance doubles (I have a default sound which starts as soon as the player joins) as a player changes a sound locally the server sound remains the same and when they both combine its not something you’d wanna hear.
Just create the sound on the client, don’t have any sound server-side. If you don’t want to create the sound instance with code, just put the default one in ReplicatedStorage and in your sound controller localScript, move the sound from replicatedStorage to playerGui and play it.
There’s a chance the issue is that the sound is replicating to the client and playing that way, and also staying in StarterGui and playing there. The solution is to not have the sound instance in StarterGui. Create the sound instance in the script using Instance.new(). This may not be the problem however, as I don’t think scripts run in StarterGui. It could be possible though.
It’s most likely something your script is doing to duplicate the sound, rather than the sound being replicated across the client-server boundary the way you describe it.
Sorry for the late reply, Creating the sound from a local script also is just the same. I think the problem is that when the server side creates its Gui the instance is being created there also.
Instead of doing script.Parent:Play() which when a server starts would start the instance playing on the cloned server I had to just do game.StarterGui.MainSound:Play() so it would do it just locally.