Problem with Build Mode

Basically I am trying to redo from scratch the wall building system from Bloxburg.
As currently I have been able to align it by 2 vector points (2 Cylinder parts) however They do not rotate correctly.
image

image

I have tried using the triangle cosine formula for getting the angle between the 2 sides however I was not really able to do it correct so could somebody please help me with this problem?

Function:

function WallPlacement()
	local ItemForDisplay = game.ReplicatedStorage.Objects.WallCylinder:Clone()
	ItemForDisplay.PrimaryPart.Orientation = Vector3.new(0,0,90)
	local PreviousCylinder:Instance = nil
	local CurrentBlock = nil
	ItemForDisplay.Parent = workspace.Temp
	
	Mouse.TargetFilter = ItemForDisplay
	
	local conn1 = Mouse.Move:Connect(function()
		ItemForDisplay:SetPrimaryPartCFrame(CFrame.new(Vector3.new(math.ceil(Mouse.Hit.Position.X), Mouse.Hit.Position.Y, math.ceil(Mouse.Hit.Position.Z))) * CFrame.Angles(0,0,math.rad(-90)))
		if Mouse.Target.Name == 'Baseplate' then
			ItemForDisplay.Fake.Color = Color3.fromRGB(0,255,0)
		else
			ItemForDisplay.Fake.Color = Color3.fromRGB(250,0,0)
		end
	end)
	
	local conn2 = Mouse.Idle:Connect(function()
		ItemForDisplay:SetPrimaryPartCFrame(CFrame.new(Vector3.new(math.ceil(Mouse.Hit.Position.X), Mouse.Hit.Position.Y, math.ceil(Mouse.Hit.Position.Z))) * CFrame.Angles(0,0,math.rad(-90)))
		if Mouse.Target.Name == 'Baseplate' then
			ItemForDisplay.Fake.Color = Color3.fromRGB(0,255,0)
		else
			ItemForDisplay.Fake.Color = Color3.fromRGB(250,0,0)
		end
		
		if Mouse.Target.Name == "Baseplate" and PreviousCylinder then
			local cframe = PreviousCylinder:GetPrimaryPartCFrame():Lerp(ItemForDisplay:GetPrimaryPartCFrame(), 0.5)
			local size = Vector3.new(0.5, 8.5, (Vector3.new(0,0,PreviousCylinder:GetPrimaryPartCFrame().Position.Z)  - Vector3.new(0,0,ItemForDisplay:GetPrimaryPartCFrame().Position.Z)).Magnitude)
			if not CurrentBlock then
				CurrentBlock = Instance.new("Part", workspace.Temp)
				CurrentBlock.Anchored = true
				CurrentBlock.CanCollide = false
				Mouse.TargetFilter = CurrentBlock
			else
				local b = (Vector3.new(0,0,PreviousCylinder:GetPrimaryPartCFrame().Position.X) - Vector3.new(0,0,ItemForDisplay:GetPrimaryPartCFrame().Position.X)).Magnitude
				local a = (Vector3.new(0,0,PreviousCylinder:GetPrimaryPartCFrame().Position.Z) - Vector3.new(0,0,ItemForDisplay:GetPrimaryPartCFrame().Position.Z)).Magnitude
				local c = math.sqrt(a^2 + b^2)
				print(a)
				print(b)
				print(c)
				local fulldegrees = math.acos(vectorA:Dot(vectorB) / (vectorA.Magnitude * vectorB.Magnitude))
				print(fulldegrees)
				local rotationCFrame = ItemForDisplay:GetPrimaryPartCFrame():ToObjectSpace(PreviousCylinder:GetPrimaryPartCFrame())
				CurrentBlock.CFrame = cframe
				CurrentBlock.Orientation = rotationCFrame.Position
				CurrentBlock.Size = size
			end
			
		end
	end)
	
	local conn3 = Mouse.Button1Down:Connect(function()
		
		if PreviousCylinder then
			CloseConnections()
			ItemForDisplay:Destroy()
			PreviousCylinder:Destroy()
		else
			PreviousCylinder = ItemForDisplay
			ItemForDisplay = game.ReplicatedStorage.Objects.WallCylinder:Clone()
			ItemForDisplay.Parent = workspace.Temp
		end
	end)
	
	table.insert(Connections, conn1)
	table.insert(Connections, conn2)
	table.insert(Connections, conn3)
end

Basically my problem is getting and applying the degrees. Variable: fulldegrees
The current formula is just from another article however no luck in working properly ofc.

The Resizing and Positioning works properly.