Triange Perlin Noise Wave Problem!

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to make a wave system with triangles.

  2. What is the issue? Include screenshots / videos if possible!


    So, here I want the edge of the triangle to follow the parts wich I move. (See the script below, it will be easier to understand.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Nothing on dev hub!

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
Triangle terrain was made with the help of EgoMoose’s 3d triangle code.
(Articles/3d triangles/3D triangles.md at master · EgoMoose/Articles · GitHub)

local X,Z = 7,7

local wedge = Instance.new("WedgePart");
wedge.Anchored = true;
wedge.TopSurface = Enum.SurfaceType.Smooth;
wedge.BottomSurface = Enum.SurfaceType.Smooth;

local function draw3dTriangle(a, b, c, parent)
	local ab, ac, bc = b - a, c - a, c - b;
	local abd, acd, bcd = ab:Dot(ab), ac:Dot(ac), bc:Dot(bc);

	if (abd > acd and abd > bcd) then
		c, a = a, c;
	elseif (acd > bcd and acd > abd) then
		a, b = b, a;
	end

	ab, ac, bc = b - a, c - a, c - b;

	local right = ac:Cross(ab).unit;
	local up = bc:Cross(right).unit;
	local back = bc.unit;

	local height = math.abs(ab:Dot(up));

	local w1 = wedge:Clone();
	w1.Size = Vector3.new(0, height, math.abs(ab:Dot(back)));
	w1.CFrame = CFrame.fromMatrix((a + b)/2, right, up, back);
	w1.Parent = parent;

	local w2 = wedge:Clone();
	w2.Size = Vector3.new(0, height, math.abs(ac:Dot(back)));
	w2.CFrame = CFrame.fromMatrix((a + c)/2, -right, up, -back);
	w2.Parent = parent;

	return w1, w2;
end

--local partSize = 3

local seed = 0

local PositionGrid = {}


for x = 0, X do
	PositionGrid[x] = {}
	for z = 0, Z do
		PositionGrid[x][z] = Vector3.new(x*5, math.noise(x /10, z / 10, seed) * 15 + 15, z*5)
	end
end


local wedge = {}


for x = 0, X-1 do
	for z = 0, Z-1 do

		local a = Instance.new("Part", workspace.PerlinNoiseTrianglePartContainer)
		a.Name = "a"
		a.Anchored = true
		a.Transparency = .5
		a.CanCollide = false 
		a.Size = Vector3.new(1,1,1)
		a.Position = PositionGrid[x][z]

		local b = Instance.new("Part", workspace.PerlinNoiseTrianglePartContainer)
		b.Name = "b"
		b.Anchored = true
		b.Transparency = .5
		b.CanCollide = false
		b.Size = Vector3.new(1,1,1)
		b.Position = PositionGrid[x+1][z]

		local c = Instance.new("Part", workspace.PerlinNoiseTrianglePartContainer)
		c.Name = "c"
		c.Anchored = true
		c.Transparency = .5
		c.CanCollide = false
		c.Size = Vector3.new(1,1,1)
		c.Position = PositionGrid[x][z+1]

		local d = Instance.new("Part", workspace.PerlinNoiseTrianglePartContainer)
		d.Name = "d"
		d.Anchored = true
		d.Transparency = .5
		d.CanCollide = false
		d.Size = Vector3.new(1,1,1)
		d.Position = PositionGrid[x+1][z+1]

		w1,w2 = draw3dTriangle(a.Position,b.Position,c.Position, workspace.PerlinNoiseTrianglePartContainer.wedge)
		w3,w4 = draw3dTriangle(b.Position,c.Position,d.Position, workspace.PerlinNoiseTrianglePartContainer.wedge)

	end
end






while wait() do	
	for i,v in pairs(workspace.PerlinNoiseTrianglePartContainer:GetChildren()) do
		if not v:IsA("Folder") then
			local x = v.Position.X
			local z = v.Position.Z
			local y = math.noise(x / 10, z / 10, seed)*15 + 10
			game:GetService("TweenService"):Create(v,TweenInfo.new(1, Enum.EasingStyle.Linear), {Position = Vector3.new(x,y,z)}):Play()
		end
	end
	seed += .1
end

So yeah, I really don’t have any idea on how to do this. I already tried to make it pop and destroy it quickly to regenerate after, but it just look bad and produce a lot of lags.