Lua Scripting

CanTouch and CanCollide: two similar properties that do opposite things

A part with CanCollide off still fires Touched — and that is what makes triggers work. Anyone wanting to stop the event needs CanTouch, which is a different property, with a different effect and a performance gain alongside.

by Gustavo Cantino9 min readIntermediate

Produced with AI from the sources cited below and checked by automated verification against those same sources. After it was published, the editor read the full text. · Reviewed by Gustavo Cantino, 11/24/26 Editorial Policy

Typographic plate with the Lua Scripting category in large type, the intermediate level below it, and a field of vertical lime green bars on a dark background.

Two BasePart properties have similar names, sit side by side in the panel and do different things: CanCollide and CanTouch.

Confusing them produces two opposite bugs — a trigger that pushes the player, and decoration that consumes performance with nobody listening.

The problem

The starting definition: a collision is when two 3D objects come into contact in the world. And BasePart has both collision events and filtering techniques, to control which assemblies collide with which.

The events occur when two BaseParts touch or stop touching, and detection is through the Touched and TouchEnded events.

And here is the sentence that separates the two properties: those events occur regardless of the parts' CanCollide.

Meaning: a part the player passes through still announces that it was passed through. That is not a side effect — it is what makes triggers, detection zones, invisible doors and objective areas possible.

The definitions, side by side:

  • CanTouch determines whether the part fires collision events. With it false, neither Touched nor TouchEnded fires.
  • CanCollide affects whether the part physically collides with others and applies force to them.

They are independent, and all four combinations have uses. A wall that also detects. A pure wall. A trigger, which you pass through and which detects. And pure decoration, which does neither.

Step by step

1. Choose the right combination for each part. The question is a double one: does this part need to push anyone? Does this part need to tell anyone?

Most of the scenery answers "yes" to the first and "no" to the second — and that is precisely where the next section's performance gain lives.

2. Connect Touched. It fires when a BasePart comes into contact with another, or with a Terrain voxel. The event sends the otherPart argument, indicating the other part involved.

3. Connect TouchEnded carefully. It fires when the part's collision bounds leave the other part's bounds, or the filled voxel's, entirely.

The word "entirely" matters: it is not when the centre leaves, it is when the last bit leaves.

4. Know what does NOT fire. The events only fire from physical movement — not from a Position or CFrame change that makes the part intersect another.

This is the cause of half the "Touched does not work" reports that exist. A script that teleports the player into a zone fires nothing; a script that moves a platform by CFrame until it touches the player fires nothing.

5. Filter at scale. Collision filtering defines which physical parts collide with which. You can configure many objects at once through collision groups, or control them pair by pair with NoCollisionConstraint instances.

And one detail that resolves a common case: the Terrain class inherits from BasePart, so you can assign a collision group to the terrain — which lets you decide whether a type of object collides with the ground or not.

Why the two properties exist separately. They answer questions from different engine systems. CanCollide belongs to the physics simulator: it decides whether there is force, whether there is a push, whether one body stops another. CanTouch belongs to the detection system: it decides whether the engine has to compute and announce that contact happened.

Separating them allows the combinations no game can live without. A trigger needs detection without physics. Scenery needs physics without detection. If they were one property, one of the two would have to be done by hand, measuring distance every frame — which is exactly what plenty of people still do without knowing they do not have to.

The artifact

The module below has two parts, and both come directly from the distinction at the start.

The first is a performance sweep that switches CanTouch off on parts tagged as decoration. The official recommendation is exactly that: CanTouch false on objects that do not need collision. Every part with the event on is a part the engine has to test against the others — even if no script listens to its event.

The second is a trigger done properly, with a correction almost every tutorial forgets: counting the parts. A character is a model of several parts, so "entered" would fire once per limb that touches, and "left" would fire on the first leg that leaves — with the player still inside the zone.

Before the mistakes, it is worth fixing the mental table that resolves almost every question on the subject, because it is short:

The part needs to...CanCollideCanTouch
push and detectonon
only push (scenery)onoff
only detect (trigger)offon
neitheroffoff

The second row is most of the map, and it is precisely the one that comes configured wrongly by default — every part is born with both on.

Common mistakes

Using CanCollide to switch off detection. It is the mistake the distinction exists to prevent. Switching CanCollide off makes the part stop pushing; the events keep firing exactly as before.

Anyone wanting the part to stop announcing needs CanTouch, and plenty of people discover that after switching CanCollide off and watching the event carry on.

Expecting an event from CFrame movement. Already described, and worth repeating because there is no error and no warning: the events are physics simulation events. Teleporting, CFrame and Position do not fire them.

The symptom is characteristic: the trigger works when the player walks into it and does not work when the game puts them there. The cause is not in the trigger.

Treating multiple firing as a bug. Touched can fire several times in rapid succession because of subtle physical collisions — and also when the collision involves a multi-part model, which is the case for any character.

It is not a defect; it is the behaviour. Ignoring it produces multiplied damage, repeated sound and wrong counts.

Reading TouchEnded as "the centre left". Since it only fires when the bounds leave entirely, a small zone with a large character may never fire the end — the player passes through and some part of them is always inside during the passage.

Leaving CanTouch on everywhere. It is the invisible cost. A map with thousands of decorative parts — leaves, wall details, objects on tables — pays the detection price on all of them, and none has a script listening.

The fix is a sweep, done once, like the artifact's. And it is safe: switching CanTouch off on a part nobody listens to changes no behaviour at all.

Using distance measurement instead of the events. It is the mistake that precedes all the others, and it comes from not knowing the trigger combination exists. A loop measuring each player's distance to each zone, every frame, does in code what the engine already does — and does it worse, because the engine knows the part's real shape and the loop only knows a point.

Forgetting that Terrain counts too. Since the Terrain class inherits from BasePart, it takes part in the collision system like any other part — Touched fires against voxels, and terrain accepts a collision group. Anyone treating the ground as inert scenery loses the tool that solves "this object must not touch the ground".

Next step

The next gain is in filtering, and it appears when the game has categories of object that need to ignore each other.

The classic case: projectiles that should not collide with each other, enemies that pass through one another, NPCs that do not push the player. Solving that with CanCollide is impossible, because the property belongs to the part and not to the relationship — either it collides with everything, or with nothing.

A collision group solves it by relationship: this group collides with that one, and not with the other. It is the right tool when the answer depends on who the part is colliding with.

And NoCollisionConstraint solves the pair-by-pair case, when two specific parts must not touch and everything else stays normal — useful for parts of the same vehicle or the same articulated machine.

It is worth taking the two tools in that order, because they answer different questions. CanCollide and CanTouch are about one part on its own; a collision group is about a part's relationship with a category. Reaching for the group first, on a problem that was only a property set wrongly, adds a layer of configuration that somebody has to maintain — and the symptom of an over-configured collision matrix is a part that stops colliding with something months later, for a reason nobody remembers.

Today's exercise is the sweep: tag your map's decoration and switch its CanTouch off. It is the best effort-to-risk optimisation on the platform — it changes no behaviour, and it takes work off the engine every frame.

Sources

How we correct mistakes

Ready-to-use artifact

A sweep that switches CanTouch off on decoration, and a trigger done properly (ServerScriptService)
lua
-- ServerScriptService: two things almost every game needs, both
-- depending on the same distinction.
--
--   CanCollide -> the part PUSHES others (physics)
--   CanTouch   -> the part FIRES events (detection)
--
-- They are independent. All four combinations exist and all have uses:
--
--   collide=on,  touch=on   a wall that also detects
--   collide=on,  touch=off  a pure wall -- most of the scenery
--   collide=off, touch=on   a TRIGGER: you pass through and it detects
--   collide=off, touch=off  pure decoration: neither pushes nor detects

local CollectionService = game:GetService("CollectionService")

local Collisions = {}

-- ── 1. PERFORMANCE SWEEP ────────────────────────────────────────────
-- The official recommendation: CanTouch false on objects that do NOT
-- need collision. Every part with CanTouch on is a part the engine has
-- to test against the others, even if no script listens to its event.
--
-- Run it in Studio, once, after tagging the decoration.
function Collisions.disableTouchOnDecoration(tag)
	local n = 0
	for _, obj in CollectionService:GetTagged(tag or "Decoration") do
		for _, d in obj:GetDescendants() do
			if d:IsA("BasePart") and d.CanTouch then
				d.CanTouch = false
				n += 1
			end
		end
		if obj:IsA("BasePart") and obj.CanTouch then
			obj.CanTouch = false
			n += 1
		end
	end
	print(n .. " part(s) with CanTouch switched off")
	return n
end

-- ── 2. TRIGGER ──────────────────────────────────────────────────────
-- A zone the player PASSES THROUGH and that detects the passage.
-- CanCollide FALSE (passes through) + CanTouch TRUE (detects).
--
-- Entering and leaving are SEPARATE events, and TouchEnded only fires
-- when the part's bounds leave the other's bounds ENTIRELY -- not when
-- the centre leaves.
function Collisions.zone(part, onEnter, onLeave)
	part.CanCollide = false
	part.CanTouch = true
	part.Anchored = true

	-- A character model has SEVERAL parts. Without counting, "entered"
	-- fires once per limb that touches, and "left" fires on the first
	-- leg that leaves -- with the player still inside.
	local inside = {}

	local function rootOf(otherPart)
		local model = otherPart:FindFirstAncestorOfClass("Model")
		return model and model:FindFirstChildOfClass("Humanoid") and model or nil
	end

	part.Touched:Connect(function(otherPart)
		local model = rootOf(otherPart)
		if not model then
			return
		end
		inside[model] = (inside[model] or 0) + 1
		if inside[model] == 1 and onEnter then
			onEnter(model)
		end
	end)

	part.TouchEnded:Connect(function(otherPart)
		local model = rootOf(otherPart)
		if not model or not inside[model] then
			return
		end
		inside[model] -= 1
		if inside[model] <= 0 then
			inside[model] = nil
			if onLeave then
				onLeave(model)
			end
		end
	end)
end

return Collisions
In this article

Keep reading