Make sounds more quiet when in a train

Pretty much, if a character enters a train, how would you make sounds more quiet? Such as the train motor, scenery sounds etc.

And then once the character exits the train, it’s back to normal.

Maybe put invisible parts that make sound outside of the train a little efar away. I can’t think of a way to make the inside more soundproof. Making the sound part outside and a little away from it will make it quieter and keep it load outside. I’m sure someone will know a better answee but that the only thing I could come up with.

I’m not sure about this, one of the ways I’ve seen other games do it is when a players character is under a roof, the sounds get more quiet. Or just the player being positioned in a train the sounds just get more quiet.

First you’d have to create a method to detect when the player is in the train. I’d probably use WorldRoot:GetPartsInPart() with an invisible part in the train.

Next, you want a way to keep track of all sounds in the game. There are many different ways you could approach this whether it’s looping through the game, using CollectionService, or storing all sounds in a Global or Module table. Once you have this information, just divide the original volume by 2 or however much you please.

There is a resource that does it:

By @MightyDantheman

I’ve made a localscript in startcharacterscripts, but if the player exits the part, how would the volume return to it’s original state? Since not all sounds have the same volume.

What happens if I can use the players camera to detect if they are in a train?