Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

0

Maybe a local script would work?

0

I'll try that but I think theres still some script missing in it.

0

Put the classname sound in the part you want it to play from & it wont play everywhere.

0

That makes sense I'll try that.

1 answer

✓ Accepted answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.