local main_part = ... -- the main part
local concerned_part = ... -- the part you want to know is touching the main part
local touching_parts = main_part:GetTouchingParts()
for i=1,#touching_parts do
local part = touching_parts[i]
if part == concerned_part then
print("the concerned part is touching the main part")
return true
end
end
Darkmist is correct, it only works with CanCollide true parts. If you’re checking parts with either CanCollide == false, it will not be in the array.
Returns a table of all parts that are physically interacting with this part. If the part itself has CanCollide set to false, then this function will return an empty table UNLESS it has a
TouchInterest
(AKA: Something is connected to its Touched event). Parts that are adjacent but not intersecting are not considered touching.