Sounds in ReplicatedStorage

I’ve already ran a 2-player offline test server and discussed with a friend regarding this topic, so I just need a third source of input before deciding what to do moving forward.

Right now, I am planning an ambience system in my game. The goal is to make it relatively primitive and easy to work with for my own sake.

Old System (Free model to be replaced):

  • Invisible brick in Workspace that has CanCollide off
  • When the brick is touched, the script changes the SoundId of the Sound object in the player’s PlayerGui if it doesn’t match the one specified in the script
  • As you can see, this is terrible because a script is trying to access a client-side element

Planned System:

  • Local script that checks what region a player’s HRP is in
  • If current region doesn’t match region during last check, play the according ambient Sound object from a Folder in ReplicatedStorage (see below)
    image

My main concern is the sound replication. I want to know if I can safely leave RespectFilteringEnabled off, have a Folder of Sound objects in ReplicatedStorage and allow clients to act on these objects directly without other clients hearing those sounds.

I’d really like to avoid any more ambience systems where soundtracks are in StarterGui or CurrentCamera, code with bad practice or free models.

I don’t know the answer to the question, though whatever the behavior is right now will probably continue to be the behavior.

However, I highly suggest turning RespectFilteringEnabled on. You will be able to play sound objects locally no matter where they are, and your players won’t have to deal with sound exploits from other players. Not only is this a better idea for your players, but with Roblox’s updates surrounding user safety (primarily against exploits recently), it’s safe to assume this option won’t exist eventually, and it may not be that far away from now. It’s better to have your game prepared.

4 Likes

Just found something.

While the above is a good solution (I should get my game compatible with RespectFilteringEnabled), wouldn’t this also answer my question that other clients would not be able to hear the sounds? Changes don’t replicate to the server or other clients. Play() changes the sound’s state to Playing.

You would need to test it. Changes don’t replicate to the server in a lot of places, however calling Play() will. ReplicatedStorage could be the same.

1 Like

Put a Sound in ReplicatedStorage, create a LocalScript in StarterPlayerScripts with only one line intended to Play the sound, start a 2-player server, enable it on Player1 but leave it disabled on Player2, turn volume off for Player1.

Basically answered my own question by looking at the Wiki and testing a second time. I’m still going to leave your response as the solution though.

  • What you said regarding the sounds could very well come to pass
  • Better to enable RespectFilteringEnabled to prevent sound exploits and for compatibility purposes
  • Friend tested a repro I made, we talked over it a bit more

image

Colb’s friend here.
Essentially-- based on the limited testing I did-- sometimes it would replicate, other times it wouldn’t.

I think it depends on what it’s parented to before replicated storage; if I parented it to the workspace and then to replicated storage, playback would replicate.

Not entirely sure. Wouldn’t rely on its behavior being consistent.

2 Likes