Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Playing music on touch within a brick, sound area. But playing to whole map?

Asked by 7 years ago
Edited 7 years ago

I have this code below I use within a brick in my shop. So when someone comes in the shop the music starts to play because the brick has been touched. The brick is invisible.

I also have another brick outside the door so when it is touched the music stops which it works. But I don't know how to make the music only be heard by the player not all players when touched.

This is the code for onTouched brick in the shop to start playing the music which works.

function onTouched(hit) 

script.Parent.Parent.Shopsound:play()  
  script.Parent.Shopsound.Pitch = 0.5
  script.Parent.Shopsound.Volume = 0.5
end 
script.Parent.Touched:connect(onTouched)

This is the code for onTouched brick outside the shop door to stop playing the music when they walk out which works.

function onTouched(hit) 
script.Parent.Parent.Shopsound:stop() 

end 
script.Parent.Touched:connect(onTouched)
0
Maybe a local script would work? Brinceous 85 — 7y
0
I'll try that but I think theres still some script missing in it. MatthewLickster 15 — 7y
0
Put the classname sound in the part you want it to play from & it wont play everywhere. Tobycats 0 — 7y
0
That makes sense I'll try that. MatthewLickster 15 — 7y

1 answer

Log in to vote
0
Answered by
cabbler 1942 Moderation Voter
7 years ago

No matter what if a sound is played in the workspace then anyone can hear it. Make a sound local by having it client-side, like simply inside the player object.

Ad

Answer this question