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)

4 comments
Maybe a local script would work?
I'll try that but I think theres still some script missing in it.
Put the classname sound in the part you want it to play from & it wont play everywhere.
That makes sense I'll try that.