Procedural River Generation

I’m trying to generate a river using noise but I get these gaps and overlaps between segments in a corner.

here’s the code for generating the river

--!strict
local ReplicatedStorage = game.ReplicatedStorage

local StartSegment = workspace.StartSegment
local Segment = ReplicatedStorage.Models.Segment

type Segment = Model & {
	Start: BasePart,
	End: BasePart	
}

local NOISE_FREQ = 1 / 12
local MAX_TURN = math.rad(27)

local function noise(x: number): number
	return math.noise(x * NOISE_FREQ) * MAX_TURN
end

local function nextSegment(lastSegment: Segment, distance: number): Segment
	local newSegment = Segment:Clone()
	
	newSegment.Parent = workspace.River
	newSegment.PrimaryPart = newSegment.Start
	
	newSegment:PivotTo(lastSegment.End.CFrame * CFrame.Angles(0, noise(distance), 0))
	
	return newSegment
end
local function generateRiver(segmentsLength: number)
	local lastSegment = StartSegment
	
	for	i = 1, segmentsLength do
		lastSegment = nextSegment(lastSegment, i)
	end	
end

generateRiver(500)

What I’m currently doing is just cloning some premade segments placing them end to end, rotating them by some noise. I want the segments to be smoothly connected without any gaps and overlaps. And is there any need of improvement to my code?

The size of the next part should be fairly close the magnitude between lastSegment & StartSegment, so just set your part Size to that. That should make it close enough not to have large gaps, but might need a little tweaking.