How do I get touching parts?

I’m making a game that revolves around car creation, and I’m making a script to check whether the player’s car is able to drive properly (all parts are connected, wheels touching suspension, etc.), but for some reason the function I’m using to check that all parts are connected isn’t working.

--CHECK IF ALL PARTS ARE CONNECTED
	for _, part in car:GetDescendants() do
		if part:IsA("BasePart") then
			local touchingParts = part:GetTouchingParts()
			
			print(touchingParts)
			local validParts = 0
			
			for _, tp:BasePart in touchingParts do
				if tp.Parent.Parent.Parent == car then
					
					validParts += 1
					continue
				end
			end
			
			if validParts == 0 then
				return false, "All parts must be connected"
			end
		end		
	end

The script works fine when the blocks are intersecting, but when they are next to eachother the script thinks that the parts aren’t touching. Is there any function that gets parts that are actually touching and aren’t just intersecting?

Maybe you can use workspace:GetPartsBoundsInBox and callibrate the size of it a little

I assume this car has welded parts, then just check if the weld is active and the parts are there via attachments’ parents.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.