Local script is playing sounds for everyone?

I’ve been trying to get a part that plays a sound for one player when they walk in a room,
and when they walk out the sounds stop playing. Since Server Scripts can’t play sounds
in the PlayerGui (I keep getting attempted to index ‘PlayerGui’ error), I put a Local Script
inside the PlayerGui and did “workspace.MusicPart.Touched:Connect(onTouch)”.

The problem is that the sounds play and stop for everyone, which I don’t understand how
that’s possible with a Local Script. Other than that it works just fine. I’d appreciate some help on this one.

So let me get this straight, you want a LocalScript to play a sound when a player touches a certain part?

Yeah, it’s an apartment building and it needs the sound to play for one person when touching it.
It works completely fine other than the fact it plays for everyone on the server despite it being a Local Script.

1 Like

There was a post similar to this that features a topic on how to make sounds play locally

You could try out the topic this reply mentioned and see if it’l lh elp to play it locally instead of globally

Thanks I’ll try checking it out. I’ve been searching for a while and still found no luck.
The last person I saw posting on this had this same issue but no response.

Anytime! Hopefully it should solve your issue as you and the OP of the post I sent both have the same issue, local script touched event causign sounds to play globally. I wish you good luck on trying to fix it!

1 Like

Thank you so much! For anyone who ends up stumbling on this issue,
I’ll post the code that helped me out:

if player.Character and part:IsDescendantOf(player.Character) then
->code here<-

You have to check and make sure the local player is the same one
that touched the part or it’s “pseudoglobal”.

That post was a lifesaver!

I’m glad that it helped you out! I recommend you put your code in a code block via
this image


It’s to help make the code you used clearer.

If you have anymore issues don’t be afraid to make another post!

1 Like