local f=10 local S=game:GetService("\080\097\116\104\102\105\110\100\105\110\103\083\101\114\118\105\099\101")local function m(f)local S={}local m=1 while m<#f do local x=f[m]table.insert(S,x)if m<#f then local S=f[m+1]local s,H,N=S.x-x.x,S.y-x.y,S.z-x.z for S=m+1,#f,1 do m=S local x=f[m-1]local X=f[m]local Q,J,D=X.x-x.x,X.y-x.y,X.z-x.z if s~=Q or H~=J or N~=D then m=m-1 break end end end end table.insert(S,f[#f])return S end local function x(f)local S={}local m=3 while m<#f do local x=f[m-2]local s=f[m-1]local H=f[m]local N=(x-s).magnitude local X=(s-H).magnitude local Q=(x-H).magnitude table.insert(S,x)if N==X then m=m+2 else m=m+1 end end table.insert(S,f[#f])return S end function CreatePathObject(f,S,m)local x={}local s={}s.Status=m function s.GetPointCoordinates(f)return S end function s.CheckOcclusionAsync(m,S)local x=0 local s=1 for f,m in pairs(f)do local H=#m:GetPointCoordinates()x=x+H if x>=S then s=f+1 local N=m:CheckOcclusionAsync((x-H)+S)if N~=-1 then return(x-H)+N end break end end for S=s,#f,1 do local m=f[S]local s=#m:GetPointCoordinates()x=x+s if s>0 then local f=m:CheckOcclusionAsync(1)if f~=-1 then return(x-s)+f end end end return-1 end return setmetatable(x,{__metatable=true,__index=s;__newindex=function()error("\067\097\110\110\111\116 \101\100\105\116 \080\097\116\104")end})end
-------------------------------------------------------------------------------
-- Core:

local MAX_PATHS = 10

local pathfindingService = game:GetService("PathfindingService")

local function SimplifyPointsStraight(points)
	local simplified = {}
	local i = 1
	while i < #points do
		local pt = points[i]
		table.insert(simplified, pt)
		if i < #points then
			local ptNext = points[i + 1]
			local dx, dy, dz = (ptNext.x - pt.x), (ptNext.y - pt.y), (ptNext.z - pt.z)
			for j = i + 1, #points do
				i = j
				local ptLast = points[i - 1]
				local pt2 = points[i]
				local dx2, dy2, dz2 = (pt2.x - ptLast.x), (pt2.y - ptLast.y), (pt2.z - ptLast.z)
				if dx ~= dx2 or dy ~= dy2 or dz ~= dz2 then
					i = (i - 1)
					break
				end
			end
		end
	end
	table.insert(simplified, points[#points])
	return simplified
end

local function SimplifyPointsDiagonal(points)
	local simplified = {}
	local i = 3
	while i < #points do
		local p1 = points[i - 2]
		local p2 = points[i - 1]
		local p3 = points[i]
		local a = (p1 - p2).magnitude
		local b = (p2 - p3).magnitude
		local c = (p1 - p3).magnitude
		table.insert(simplified, p1)
		if a == b then
			i = (i + 2)
		else
			i = (i + 1)
		end
	end
	table.insert(simplified, points[#points])
	return simplified
end

function CreatePathObject(paths, points, finalStatus)
	local path = {}
	local api = {}
	api.Status = finalStatus
	function api:GetPointCoordinates()
		return points
	end
	function api:CheckOcclusionAsync(start)
		local n = 0
		local startIndex = 1
		for i, p in pairs(paths) do
			local numPoints = #p:GetPointCoordinates()
			n = (n + numPoints)
			if n >= start then
				startIndex = i + 1
				local test = p:CheckOcclusionAsync(n - numPoints + start)
				if test ~= -1 then
					return (n - numPoints + test)
				end
				break
			end
		end
		for i = startIndex, #paths do
			local p = paths[i]
			local numPoints = #p:GetPointCoordinates()
			n = (n + numPoints)
			if numPoints > 0 then
				local test = p:CheckOcclusionAsync(1)
				if test ~= -1 then
					return (n - numPoints + test)
				end
			end
		end
		return -1
	end
	return setmetatable(path, {
		__metatable = true,
		__index = api,
		__newindex = function()
			error("Cannot edit Path")
		end,
	})
end
