How to detect a collision event and not a touch event?

hello developers,

I just ran into a problem and would like someone to help me if you know a solution. The problem is that I am using Touched to detect if I can place the object or not, and it doesn’t work because even if the object doesn’t collide with the floor, it still hits the floor, and the touch event detect the floor, so it doesn’t let me place it.

Check collision function:

PlacementProperties.checkCollision = function(object)
for i, v in pairs(PlacementProperties.getModelParts(object)) do
	local touched = v.Touched:Connect(function() end)
	local collidingObject = v:GetTouchingParts() -- Gets all individual touching parts including children touching each other
	if collidingObject ~= nil then
		for i, v in pairs(collidingObject) do
			if (not v:IsDescendantOf(object)) then
				return false -- colliding
			end
		end
	end
	touched:Disconnect()
end
   return true
end

Demonstration:
This is a clip of a table that I lift up a bit so that it doesn’t hit the floor and I can place it: https://gyazo.com/548c6addc92c513fd3549faf3aeda448
This a clip of a wall that isn’t lifted up like the table and I can’t place: https://gyazo.com/b156972c8305c84e4e41f24b3cf50da7

SORRY FOR THE BACKGROUND NOISES IN THE CLIPS

Any suggestion? Is there anything else that can replace the touch event, like a collision event?

BasePart:GetCollidingParts() may do the trick.

Does that really exist, I don’t think so…? let me check
Edit: it doesnt exist

Sorry I was replying to the wrong post however this is what I think would help: BasePart | Roblox Creator Documentation

1 Like

that’s what I used in my script…

Possibly adding extra parts above the bottom which will be checked with GetTouchingParts