I’m using this resource, but how can I fix this hole?
here is my script
local function CreatePolygonFromPoints(Points)
local Polygon = {}
local First = Polygon
for i = 1, #Points do
Polygon.Position = Points[i]
Polygon.NodeId = i
if i ~= #Points then
Polygon.Next = {Previous = Polygon}
Polygon = Polygon.Next
end
local A, B, C = GetPoint("Behind", i, Points), Points[i], GetPoint("Front", i, Points)
drawTriangle(A, B, C, workspace.Debug)
end
Polygon.Next, First.Previous = First, Polygon
return First
end
function GetPoint(Type, Point, ListofPoint)
if Type == "Behind" then
if Point == 1 then
return ListofPoint[#ListofPoint]
else
return ListofPoint[Point - 1]
end
elseif Type == "Front" then
if Point == #ListofPoint then
return ListofPoint[1]
else
return ListofPoint[Point + 1]
end
end
return false
end
local wedge = Instance.new("WedgePart")
wedge.Material = Enum.Material.SmoothPlastic
wedge.Transparency = 0
wedge.Anchored = true
wedge.CanCollide = false
wedge.TopSurface = Enum.SurfaceType.Smooth
wedge.BottomSurface = Enum.SurfaceType.Smooth
wedge.Color = Color3.fromRGB(125, 125, 125)
local wedgeMesh = Instance.new("SpecialMesh", wedge)
wedgeMesh.MeshType = Enum.MeshType.Wedge
wedgeMesh.Scale = Vector3.new(1,1,1)
function drawTriangle(a, b, c, parent)
local edges = {
{longest = (c - b), other = (a - b), position = b};
{longest = (a - c), other = (b - c), position = c};
{longest = (b - a), other = (c - a), position = a};
};
table.sort(edges, function(a, b) return a.longest.magnitude > b.longest.magnitude end);
local edge = edges[1];
local theta = math.acos(edge.longest.unit:Dot(edge.other.unit))
local s1 = Vector2.new(edge.other.magnitude * math.cos(theta), edge.other.magnitude * math.sin(theta));
local s2 = Vector2.new(edge.longest.magnitude - s1.x, s1.y);
local p1 = edge.position + edge.other * 0.5
local p2 = edge.position + edge.longest + (edge.other - edge.longest) * 0.5
local right = edge.longest:Cross(edge.other).unit;
local up = right:Cross(edge.longest).unit;
local back = edge.longest.unit;
local cf1 = CFrame.new(
p1.x, p1.y, p1.z,
-right.x, up.x, back.x,
-right.y, up.y, back.y,
-right.z, up.z, back.z
);
local cf2 = CFrame.new(
p2.x, p2.y, p2.z,
right.x, up.x, -back.x,
right.y, up.y, -back.y,
right.z, up.z, -back.z
);
local w1 = wedge:Clone();
local w2 = wedge:Clone();
w1.Parent = parent;
w2.Parent = parent;
w1.Size = Vector3.new(0.01, s1.y, s1.x);
w2.Size = Vector3.new(0.01, s2.y, s2.x);
w1.CFrame = cf1;
w2.CFrame = cf2;
end;
local points = {}
for i, v in next, workspace.Model:GetChildren() do table.insert(points, v.Position) end
CreatePolygonFromPoints(points)
I have no idea how to fix this