Grid snapping off by half a stud when size of object trying to snap is odd

I’m using this code to snap to a grid:

local function Snap(vec)
	local PosX = math.floor(vec.X / GridSize + 0.5) * GridSize
	local PosY = math.floor(vec.Y / GridSize + 0.5) * GridSize
	local PosZ = math.floor(vec.Z / GridSize + 0.5) * GridSize
	
	return Vector3.new(PosX, PosY, PosZ)
end

Build:SetPrimaryPartCFrame(CFrame.new(Snap(mouseRay.Position))
-- mouseRay being a ray from the camera to the mouses position

This works fine with objects that have a size that are even, such as (4,4,4) but when the size of the object is odd it will snap half a stud off which can interfere and collide with objects that have an even size.