PcoWSkbVqDnWTu_dm2ix
Collapse Sidebar

CanTouch

BasePart

bool

This property determines if the part will trigger BasePart/Touched|Touched/BasePart/TouchEnded|TouchEnded events on other BasePart|BaseParts with TouchTransmitter|TouchTransmitters. By default, the value is set to true.

A BasePart’s Touched or TouchEnded event will only fire if otherPart has CanTouch set to true.

When false, a touch event cannot be setup for the part. Attempting to do so will throw an error. If the property is set to false after a touch event is connected, the event will be disconnected and TouchTransmitter removed.

The two images below demonstrate how the property behaves using a non-colliding part with a script telling it to turn green when touched. First, on the left, we drop parts that are CanTouch. On the right, we drop parts that are not CanTouch.

Collision Groups

This collision logic can be enabled and disabled for articles/Collision Filtering|Collision Groups using the Workspace/TouchesUseCollisionGroups property. In this case, when TouchesUseCollisionGroups is true parts in different groups set to not collide will ignore collisions and touch events - thereby ignoring this property

Performance

There is a small performance gain on parts that have both CanTouch and BasePart/CanCollide|CanCollide set to false, as these parts will never need to compute any kind of part to part collisions. However, they can still be hit by WorldRoot/Raycast|Raycasts and DataType/Region3|Region3 queries.