How do I get rid of these kinds of faces? I'm unsure why or how they keep popping up...

So, I’m pretty new to creating my own meshes in Unity, and I learned the basics from a Brakceys tutorial. However, I started to notice that, after I use Perlin Noise to change certain vertices’ height, strange faces keep appearing, most of which seem to be connected to the first vertice. Does it have to do with the way Unity’s meshes handle vertices? I know I am under the limit, which is, I believe, 65536 (256 * 256). Any help would be appreciated greatly. Here’s the code I used to generate the mesh:

private class Island
    {
        private int sizeInVerts;

        public int SizeInVerts
        {
            get { return sizeInVerts; }
        }

        private Vector3 position;

        public Vector3 Position
        {
            get { return position; }
        }

        private Mesh mesh;

        public Mesh IslandMesh
        {
            get { return mesh; }
        }

        private GameObject meshObject;

        public GameObject MeshObject
        {
            get { return meshObject; }
        }

        public Island (int _sizeInVerts, Vector3 _position)
        {
            sizeInVerts = _sizeInVerts;
            position = _position;

            mesh = new Mesh();

            meshObject = new GameObject();
            meshObject.name = position.ToString();
            meshObject.transform.position = position;
            meshObject.transform.parent = GameObject.Find("Islands").transform;

            meshObject.AddComponent<MeshCollider>().sharedMesh = mesh;
        }

        private Vector3[] MeshVerts;
        private int[] MeshTris;

        private void UpdateMesh()
        {
            MeshFilter meshFilter = meshObject.AddComponent<MeshFilter>();
            MeshRenderer meshRenderer = meshObject.AddComponent<MeshRenderer>();

            var GrassMat = Resources.Load("Materials/Grass_Mat") as Material;
            meshRenderer.materials = new Material[] {GrassMat};

            mesh.Clear();

            mesh.vertices = MeshVerts;
            mesh.triangles = MeshTris;

            meshFilter.mesh = mesh;
           
            mesh.RecalculateNormals();

            meshObject.transform.position = position;
        }

        public void Generate()
        {
            MeshVerts = new Vector3[(SizeInVerts + 1) * (SizeInVerts + 1)];
            MeshTris = new int[SizeInVerts * SizeInVerts * 6];

            int Vert = 0;
            int Tri = 0;

            // Create Vertices
            for (int x = 0; x < SizeInVerts; x++)
            {
                for (int z = 0; z < SizeInVerts; z++)
                {
                    // 0.025 / 2
                    float YNoise = Mathf.PerlinNoise(x * 0.025F / 2, z * 0.025F / 2);
                    float YValue = 0;
                   
                    if (YNoise >= 0 & YNoise <= 0.40F)
                    {
                        YValue = 0;
                    }
                    else if (YNoise > 0.40F & YNoise <= 0.50F)
                    {
                        YValue = 3;
                    }
                    else if (YNoise > 0.50F)
                    {
                        YValue = 5;
                    }

                    // Create new Vertice using x and z
                    Vector3 NewVert = new Vector3(x, YValue, z);
                    MeshVerts[Vert] = NewVert;
                   
                    Vert++;
                }
                Vert++;
            }

            print("Vert: " + Vert);

            Vert = 0;

            for (int x = 0; x < SizeInVerts; x++)
            {
                for (int z = 0; z < SizeInVerts; z++)
                {
                    // Create new Trianges
                    MeshTris[Tri + 0] = Vert + 0;
                    MeshTris[Tri + 1] = Vert + 1;
                    MeshTris[Tri + 2] = Vert + SizeInVerts + 1;
                    MeshTris[Tri + 3] = Vert + 1;
                    MeshTris[Tri + 4] = Vert + SizeInVerts + 2;
                    MeshTris[Tri + 5] = Vert + SizeInVerts + 1;

                    Vert++;
                    Tri += 6;
                }

                Vert++;
            }

            UpdateMesh();
        }

I just realized that I haven’t been commenting very much code, but, for the most part, the code should be easily understood…

Edit:
These faces also exist before I add noise, as you can see diagonal shadows going across the mesh.

You know you can use 32 bit meshes too since several years? Look in the documentation. You just have to set an enum to have more space available.

    Vert++;
}
Vert++;

It’s hard to debug such “complex” code just from seeing it, but this seems fishy. You increment vert in the outer loop without adding something so I suspect you produce some kind of “gap”. I would try with the second one commented out. Same for the triangle loop.

MeshVerts = new Vector3[(SizeInVerts + 1) * (SizeInVerts + 1)];
vs.
for (int x = 0; x < SizeInVerts; x++)

It appears your array is too large. But this may have to do with your extra increment.

I suggest your set sizeInVerts to a small number (like 3) and step through the code to verify it’s correctness. It also helps to draw the different steps (vertext creation, triangle assignment) on paper. If all fails have a look like others did it as there are plenty of examples/tutorials with regular grids. CatlikeCoding did a good one IIRC.