How do i snap cubes together like minecraft

im making a minecraft replica and how do i snap cubes together

all i want is to snap multiple cubes together like minecraft please and thanks.

function Update()
{
   if (playerFullfillsConditionsToSnapCubesTogether)
   {
      SnapCubes();
   }
}

function SnapCubes()
{
   transform.position = VariableThatMakesACubeAppearToSnapNextToAnotherCube;
}

function UnspecificQuestion()
{
   if (UserAsksUnspecificQuestion)
   {
      UserRecievesUnspecificAnswer();
   }
   if (UserCanBeMoreInformativeInTheirQuestion && UserEditsQuestionToIncludeRelevantData)
   {
      UserRecievesALotBetterHelp();
   }
}