How can I play a sound via drag detector part touch

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I am unsure of how I would be able to play a sound when an anchored limited drag detector touches another anchored part/reaches a certain position.

  2. What is the issue? Include screenshots / videos if possible!

I do not know how I would be able to play a sound when the green part touches the red part (both are anchored to .Touched doesn’t work.

  1. What solutions have you tried so far?
    I’ve tried to look into documentation but I haven’t found a definite solution, neither on YouTube either.

Are you dragging and moving by changing the part’s position or is it using Roblox physics? Changing the part’s position when it is anchored will not fire touch. What you can do however is check to see if the position the part is moving to will touch the other part

It is not using roblox’s physics, the green part is an anchored part that uses the drag detector built in with roblox

note: red part is also anchored too

How would I be able to do that? Is there any specific thing I could do to check that?

I’m assuming the drag detector is an event. You would want to find the position of the edge of the part and add something like 0.05 in the direction you are dragging. For position in part, you can use this post Check if position is in part - Help and Feedback / Scripting Support - Developer Forum | Roblox

I’ve actually tried this exact script from this dev post and it did kindof work, but the problem was that the sounds kept on playing constantly instead of just playing once

In that case, you need to set a debounce or boolean saying that if the sound has already been played, it should not play the sound again

I made a horrible finicky solution, but I used two scripts, one for the back position and one for the front. I also used debounce along with “soundresovoirs” where I can store the sound. It works, but I probably will just change it to create a sound later. Thanks for all the help!

1 Like

Another important note for anyone doing it with two detection parts at the end, I found out that it is VERY easy if you just use “break” out of the while loop in the script.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.