Add faces to editablemesh that has varrying vertices

I created this function that creates a cylinder where you can input the amount of sides the cylinder has.

local function CreateCylinder(Edges:number)
	local emesh = AssetService:CreateEditableMesh()
	local Vertecies = {}
	local Angle = 360
	local CurrentAngle = 0
	
	
	for i = 1, Edges do
		
		local x, y = sin(CurrentAngle), cos(CurrentAngle)
		
		table.insert(Vertecies ,emesh:AddVertex(Vector3.new(x, 1, y)))
		table.insert(Vertecies, emesh:AddVertex(Vector3.new(x, 0, y)))
		
		CurrentAngle += Angle/Edges
	end
	
	return emesh
end

My issue is that I am unsure about how to go about adding the faces reliably as Iā€™m not familiar with the EditableMesh class.

can anyone help me out?

1 Like