I tried googling this but all that came up was if the player touched the part. Can somebody show how to do this?
✓ ANSWER ACCEPTED
How can I test for when two parts touch?
1 answer
✓ Accepted answer
local part = script.Parent
part.Touched:connect(function()
local touching = part:GetTouchingParts()
for parts,touchingpart in pairs (touching) do
print(touchingpart.Name)
end
end)
This script prints the names of all parts that touch the part
local part = script.Parent
part.Touched:connect(function()
local touching = part:GetTouchingParts()
if #touching == 2 then
--script here
end
end)
this script executes your code when 2 parts touch the part
this sometimes bugs so i would prefer to use this:
local part = script.Parent
wait ()
while true do
wait ()
local touching = part:GetTouchingParts()
if #touching == 2 then
--script here
end
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

4 comments
:GetTouchingParts()
how would I use it?
https://scriptinghelpers.org/questions/38426/how-would-i-use-gettouchingparts-and-check-the-names-of-the-parts-it-returns
If you connect to .Touched it returns the part that touched it.