How to toggle on and off Sound when touch part?

As you read from the title. You can see that I need to know Sound Scripts such as like how do I make the sound turn on/off when touch a part? This is very helpful since I’ve been experiencing a lot of problems with Sound Regions.
If you didn’t understand what I wrote, I meant Toggling On and Off the Playing Button which is found in Sounds - Properties.
PLAYING
If you know anything related to this please leave down a reply.
Thanks!

2 Likes

you just make the sound not loop so when you play it when touching the part it will play the sound and you don’t need to turn it off

1 Like

you can just do script.Parent.SoundName:Play() if you want to play the sound
and if you want it to pause script.Parent.SoundName:Pause()

2 Likes

I’m making a rain sound effect, If I turn loop off it will turn off unexpectedly which I don’t want to happen. Is there a way where I can keep it looping but I can pause it perhaps. Just like what you said?

Thank you for your help!

1 Like

make it loop already then just play the sound when player touch the part

1 Like

i hope you know how to use the touch event

1 Like

I do know how, Thank you for asking

Noted! Thanks I will try it out and give you my feedback!

1 Like

Here is an example if you didn’t touch the part it will not play and if you touch the part the sound will play https://gyazo.com/1a088603609e5a4b5fe69a0b073d2609

1 Like

you just need to do
I made the script simple
script.Parent.Touched:Connect(function(hit)

script.Parent.Sound:Play()

end)

script.Parent.TouchEnded:Connect(function(hit)

script.Parent.Sound:Stop()

end)

1 Like

I’d like to add, use :Resume() if you want to resume the sound, as using :Play() will make it play from the beginning

1 Like

there is pause,stop,play and resume

2 Likes