How do i make my building system not clip blocks when the mouse is on the block's side

  1. I want to make my building system not clip blocks when the mouse is on one’s side, an example of what i want here:
    image

  2. My parts clip into eachother on the side
    image

  3. I already fixed the issue with the Y axis but i have no clue on how to fix it for the X and Z axis

This is extremely important for my build system, there will be different grid snaps and rotations that i want to offset

You could offset the position of the block when it is attached to a block’s face on the sides.

had the same problem, fixed it by using raycasts

local target,pos,norm = nil

function UpdatePosition()
	local ignoreList = {}
	if circle ~= nil then
		table.insert(ignoreList,circle)
	end
	local mouseRay = mouse.UnitRay
	local newRay = Ray.new(mouseRay.Origin, mouseRay.Direction.Unit * 10000)
	target, pos, norm = workspace:FindPartOnRayWithIgnoreList(newRay, ignoreList)


end
	UpdatePosition()
local endPos = pos + (norm * (part.Size * 0.5))
Part.Position = endPos

thanks, but is there a way to do this with CFrame? i wanna be able to do this with rotated parts as well

yeah, just make the endpos cframe.new endpos im pretty sure

you guys on dev forum are the best people i know, thank you so much

hey again, it seems i have a problem with the offset working for rotation, do you know how to fix it?
image

are you using cframe or oriantation to rotate?

i’m using cframe to rotate it, cframe.angles

so whats the problem exactly? I don’t think I undestand lol

i want to make the blocks offset with rotation properly, in this image, the blocks offset properly
image
but as soon as i add rotation into the mix, it messes up the placement
image