How to make better placement system? (all side colllision)

I am trying to achieve an collision between object that player is placing and other objects, for all sides not only for 3 sides. Any ideas?

Here is what I’ve already tried, but also the object is bit off the players cursor:

            local PosX
	        local PosY
			local PosZ
				
			local Model = (UIs:WaitForChild("Configuration"):WaitForChild("ConstructionObject").Value):Clone()
			Model.Parent = workspace
				
			local GridSize = 2
				
			local function Snap()
				if UIs:WaitForChild("Configuration"):WaitForChild("ConstructionMode").Value == true and Model ~= nil then
					PosX = math.floor((Mouse.Hit.X + Model.PrimaryPart.Size.X / 2) / GridSize + 0.5) * GridSize
					PosY = math.floor(Mouse.Hit.Y + Model.PrimaryPart.Size.Y / 2 + Model.PrimaryPart.Size.Y / 2)
					PosZ = math.floor((Mouse.Hit.Z + Model.PrimaryPart.Size.Z / 2) / GridSize + 0.5) * GridSize
				end
			end
			
			local function Movement()
				if UIs:WaitForChild("Configuration"):WaitForChild("ConstructionMode").Value == true and Model ~= nil then
					Mouse.TargetFilter = Model
					Snap()
					Model:SetPrimaryPartCFrame(CFrame.new(PosX, PosY, PosZ))
				end
			end
			
			Mouse.Button1Down:Connect(function()
				if UIs:WaitForChild("Configuration"):WaitForChild("ConstructionMode").Value == true and Model ~= nil then
					Mouse.TargetFilter = Model
					Snap()
					local SharedModel = UIs:WaitForChild("Configuration"):WaitForChild("ConstructionObject").Value
					ReplicatedStorage:WaitForChild("PlaceConstruction"):FireServer(SharedModel, PosX, PosY, PosZ)
					Model = nil
					UIs:WaitForChild("Configuration"):WaitForChild("ConstructionMode").Value = false
				end
			end)
			Mouse.Move:Connect(Movement)

If you have any suggestions how to make all side collision and some other improvement to script, please tell. If possible provide an example for usage of your method.