How to let the player drag an object with collision to other objects?

Hello there,
I am working on a system that enables the player to drag a part around.
Everything works fine, except the fact that the part is sticking halfway in the floor or wall or whatever.
b7f9f96bac1d952599fd15c2618acd01

I already have a solution to this problem but… it’s not effective and doesn’t work at corners.
And the solution doesn’t make me feel yummi, yk?

local function POS_UPADTE()
	if mouse.Target then
		part.CFrame = mouse.Hit
		if part.Touched then
			if mouse.TargetSurface.Name == "Top" then
				part.CFrame = part.CFrame + Vector3.new(0,part.Size.Y/2,0)
			elseif mouse.TargetSurface.Name == "Front" then
				part.CFrame = part.CFrame + Vector3.new(0,0,-part.Size.Z/2)
			elseif mouse.TargetSurface.Name == "Right" then
				part.CFrame = part.CFrame + Vector3.new(part.Size.X/2,0,0)
			elseif mouse.TargetSurface.Name == "Bottom" then
				part.CFrame = part.CFrame + Vector3.new(0,-part.Size.Y/2,0)
			elseif mouse.TargetSurface.Name == "Back" then
				part.CFrame = part.CFrame + Vector3.new(0,0,part.Size.Z/2)
			elseif mouse.TargetSurface.Name == "Left" then
				part.CFrame = part.CFrame + Vector3.new(-part.Size.X/2,0,0)
			end
		end
	end
end

484d82bdee4b0a12910748d4f96c5221

so I need help or hints to handle this problem, in the end, you shouldn’t be able to push it inside other parts anymore … some ideas?

The problem is that it only takes into account the object that the mouse is on. Maybe use a raycast from the center of the part to detect those other parts, and using the logic that you used for the floor detection.

Good idea, I gonna look into that… I will of course update this topic if I have the solution.

found somthing and new questions apeared and I made a new topic for this