Prevent furniture from sinking into part

Currently I’m making a furniture placement system where on key pressed a clone of the model is created and follows the mouse position.
However the problem is the model seems to clip into parts pictured below.
I had initially played with the idea of adding the floors y size to the tables CFrame but that only raises the part by one stud, not to mention it wouldn’t work if the floor was very thick.

Local Script

	CreatedFurniture = true
		if CreatedFurniture then
			for i, v in pairs(Table:GetChildren()) do  -- Table is the furniture model
				if v.Name ~= "GridPart" then  -- Gridpart is the primary part
					v.Transparency = 0
			SnapFurniture()	-- "Snaps" furniture to grid
			mouse.TargetFilter = Table
			local floor = mouse.Target
			Table:SetPrimaryPartCFrame(, posY, posZ)))	-- Pos values from SnapFurniture function
1 Like

raycast down from each table leg to get the height of the table. Also do a raycast from each corner to the center to see if’s intersecting anything or do #hitbox:GetTouchingParts()>ThatAmountOfPartsThatWouldNormallyBeInTheHitBox

Okay, but you haven’t elaborated on how this could stop the item from clipping into the part.
E.g: What would I do afterwards?

1 Like

You do checks to see if the part is clipping or if it’s grounded. If it’s clipping don’t let them place it. If it’s not grounded move it up or down accordingly.

You’ll need to find the height of the model. Usually what I do is have a transparent part that covers the entire model and acts as its collision box, and then you can find the height by simply finding the Y component of this parts size. Then, you just add half of this height to the Y component of your CFrame. That would be done in this part:

Table:SetPrimaryPartCFrame(, posY + sizeY/2, posZ)))
1 Like