Random Island generation using Perlin Noise ?

Hello, I am in need of Help.

I am trying to create a generator that is using Perlin noise.


What I am trying to create are islands that are created from hexagons or cubes and not one big mesh.
I want to use Perlin noise to create more natural looking Islands.


I have tried to follow tutorials created by Sebastian Lague but I have problems understanding half of his code and his coding method.

What I want.


What I have managed to create.

My question is How do I “repair” the code so I get the result as in picture 1 ?

Here is my code.

public class Noise : MonoBehaviour
{
    public int width;
    public int height;

    public float scale;

    [Range(0, 1)]
    public float persistance;
    public float lacunarity;

    int offsetX;
    int offsetY;
    public float noiseHeight;

    Renderer render;

    public  int octaves;
    

    private void Start()
    {
            offsetX = Random.Range(0, 99999);
            offsetY = Random.Range(0, 99999);      
    }
    void Update()
    {
        render = GetComponent<Renderer>();
        render.material.mainTexture = GenerateTexture();
    }

    Texture2D GenerateTexture() 
    {
        Texture2D texture = new Texture2D(width, height);

        for(int x = 0 ; x < width; x++) 
        {
            for (int y = 0; y < height; y++)
            {

                float amplitude = 1;
                float frequency = 1;
                noiseHeight = 0;

                for (int i = 0; i < octaves; i++)
                {
                    float xCoord = x / scale * frequency + offsetX;
                    float yCoord = y / scale * frequency + offsetY;

                    float sample = Mathf.PerlinNoise(xCoord, yCoord) * 2 -1;
                    noiseHeight += sample * amplitude;

                    amplitude *= persistance;
                    frequency *= lacunarity;
                }
                Color color = CalculateColor(noiseHeight);
                texture.SetPixel(x, y,color);
            }
        }
        texture.Apply();
        return texture;
    }

    Color CalculateColor(float noiseHeight) 
    {    
        return new Color(noiseHeight, noiseHeight, noiseHeight);
    }
}

I would suggest not using perlin noice but rather a survivel model to randomly generating islands. This works by first randomly placing tiles on a tilemap of your chosen size(choosing from water tile and land tile) and then using a forloop to go through each of the tiles to check their neighbors. Based on the amount of similar or diffrent tiles the script either changes or leaves the tile. This can be repreated for a smoother result. If you want i can explain it further and give some code, but im to lazy to do so without knowing if youd use it or not. The results are pretty similar though.