Local Sounds with Global Triggers?

Essentially, I have a car, with a brick sticking out either side. (The brick is invisible, and cannot collide.)
image
Sorry for my sick art skills.

And now imagine two of these cars driving around an oval track. There are to sounds inside of the vehicleseat. One relates to the left block, and the other relates to the right block. When the two cars are side by side, and the left block of car A touches the vehicleseat of car B, the driver of car A will hear the sound correlating to the left block. The driver in car B would have their right block touching the vehicleseat of car A, and thus would hear the sound correlating to the right block. Each driver would only hear the sound that is being generated by their specific car.

I did various tests and the best I could get is everyone in the server hearing the sound cars were producing. So I guess:

  1. Can sounds be played locally? (To only one person out of the entire server)
  2. If so, can that be done with global triggers like I’m describing?

If you play sounds with a LocalScript then they should only be heard locally[1]. You might need to make the Sound objects locally too, I’m not sure. If so, you could clone an existing Sound object and play the cloned version.

  • The best way to do this would be to have the LocalScript watch for the player’s character to sit in a VehicleSeat, get the left/right parts, and play the sounds when appropriate using .Touched
  • An alternative would be to use a RemoteEvent and have the server tell the client when to play the sounds.

[1] If your game is in Experimental Mode, then you’re going to have to play the sounds from non-replicating containers such as the player’s Camera

2 Likes

Exactly what I was going to say.

If you go into SoundService in your game, there is a toggle called “RespectFilteringEnabled” that will stop Play() from replicating from local scripts

6 Likes

I’ll have to look into this a bit more tomorrow. I was using a local script, but still getting everyone to hear it, so yeah, gonna have to make the sounds local as well. There isn’t much evidence in the wiki about making sounds heard locally… kinda leaves me wondering why not.

Make sure you check out the property madattak suggested first. You might be able to toggle that to true and be done. If the property doesn’t work, make sure FilteringEnabled is true/Experimental mode is off.

1 Like

You could parent the sound to PlayerGui or Backpack to play it locally.

1 Like

I figured out how to do it super unconventionally.
Basically, using a local script that looks for a value inside the vehicleseat, and that value relays whether or not to play the sound. The sounds are nested in PlayerGUI. And the bricks each have a hit function to change the value in the vehicle seat to correspond to the sounds.

Probably could use simplifying it down, but it works right now, so that’s good.

Thanks for the various tips and tricks everyone.

Make sure to mark your post as the solution so others who don’t notice that you’ve solved your problem don’t reply with more solutions to a solved problem. It’s the box by the edit button.