How To Fill Gap Underneath Generated (Perlin Noise) Terrain?

Hello Devs, Im new to perlin noise terrain generator thing, so i have a question. How can i fill the gaps underneath the generated terrrain

Jepretan Layar 2022-04-07 pukul 15.32.11

My Problem Is: My current script keep Stacking In One Place And Not Fill the Gap.

Actually this is my script if you want to see

        for i,v in pairs(workspace.Baseplate:GetChildren()) do
			if v:IsA("BasePart") then
				if  v.Position.Y > LastHeight then
					local part = rs:FindFirstChild("Terrain"):FindFirstChild("Stone"):Clone()
					part.Parent = partContainer
					part.Size = Vector3.new(4,4,4)
					part.Anchored = true
					part.Position = Vector3.new(v.Position.X,LastHeight,v.Position.Z)
				end
			end
		end

The “LastHeight” is getting the highest part ( for me is 24 ) and subtracted by “Part.Size.Y” ( for me is 4), every for loop done.

But the thing is, they keep stacking each other, like in one position there was 2 part or more. I dont think this was for loop bug or smth

So you want to fill between the green and baseplate?
Instead of putting a green Part 10 studs high at your Perlin noise height and then putting a 30 stud high brown Part right under it, place the brown Part at half the height from the base to the bottom of the green Part and make it that height.
Say you place a 10 stud high green Part at 100 studs high off the baseplate. I’m just using Y Position 0 as the top of the baseplate’s surface.
You’d need a brown Part that is 100-half of the green Part's height placed at half that value’s Y Position.
So:
greenHeight = 10
greenPosition = 100 --your perlin Y value
brownHeight = greenPosition - (.5 * greenHeight) --if all your green Parts are 10 studs then just make it greenPosition-5
brownPosition = brownHeight / 2

yea, actually this is my script if you want to see

        for i,v in pairs(workspace.Baseplate:GetChildren()) do
			if v:IsA("BasePart") then
				if  v.Position.Y > LastHeight then
					local part = rs:FindFirstChild("Terrain"):FindFirstChild("Stone"):Clone()
					part.Parent = partContainer
					part.Size = Vector3.new(4,4,4)
					part.Anchored = true
					part.Position = Vector3.new(v.Position.X,LastHeight,v.Position.Z)
				end
			end
		end

The “LastHeight” is getting the highest part ( for me is 24 ) and subtracted by “Part.Size.Y” ( for me is 4), every for loop done.

But the thing is, they keep stacking each other, like in one position there was 2 part or more. I dont think this was for loop bug or smth