local function g(g)local h={g[1].Position}local l=(g[2].Position-g[1].Position).Unit if#g>2 then for V=2,#g-1,1 do local G=(g[V].Position-h[#h]).Unit if not G~=l then table.insert(h,g[V].Position)l=G end end end return h end return function(h,l,V)if V then path=PathfindingService:CreatePath()end path:ComputeAsync(h,l)if path.Status==Enum.PathStatus.Success then local h=g(path:GetWaypoints())return h else return false end end
--Func
local function condensePath(paths)
	local newWaypoints = {
		paths[1].Position,
	}
	local lastUnit = (paths[2].Position - paths[1].Position).Unit

	if #paths > 2 then
		for i = 2, #paths - 1 do
			local thisUnit = (paths[i].Position - newWaypoints[#newWaypoints]).Unit

			if not thisUnit ~= lastUnit then
				table.insert(newWaypoints, paths[i].Position)
				lastUnit = thisUnit
			end
		end
	end

	return newWaypoints
end

return function(pointA, pointB, refreshPath)
	if refreshPath then
		path = PathfindingService:CreatePath()
	end
	path:ComputeAsync(pointA, pointB)

	if path.Status == Enum.PathStatus.Success then
		local waypoints = condensePath(path:GetWaypoints())

		return waypoints
	else
		return false
	end
end
