How could I convert my terrain generator to a realistic island generator?

Hello, I’m making a flat terrain generator, and I made it, now I want it to look more natural by generating archipelagos, but I don’t really know how to implement it.

The generator’s code:

local x = 40
local z = 40
local y = 1

local grid = 1

for x = -x, x, 1 do
	for z = -z, z, 1 do
		
		local chance = math.random(1, 2)
		
		if chance == 1 then
			local part = Instance.new("Part", game.Workspace.Provinces)
			part.Size = Vector3.new(1, 1, 1)
			part.Position = Vector3.new(x, y, z)
			part.BrickColor = BrickColor.new("Dark green")
			part.Anchored = true
			part.Name = "Province"
		end
	end
end

Here’s how looks my terrain generator:

And how I want it to look like (or similar):

I would like to hear your opinion and ideas or resources of how I could do this.
Thanks in advance.

You’re looking for math.noise(x, y?, z?)! More commonly know as perlin noise.

Perlin noise is similar to math.random but it asks for a position rather than a minimum and a maximum number and positions that are close to each other tend to have close values!

To increase smoothness multiply the position you want by a small value like .05 etc. to decrease it multiply it by a larger value.

An important note is perlin noise generally returns numbers between -1 and 1 but it can go past those in rare situations it also tends to break if you feed it large numbers so be mindful of that.

thank you very much that is useful for me :slightly_smiling_face:

sorry for not answering.