The tiles don't seme to render correctly for some reason

Godot Version

4.4.1

Question

I’m trying to improve my procedurally generated terrain so it includes the transition tiles between the grass and sand (I’ll eventually include the transition tiles between the sand and water.). However, on my first trial, the tiles don’t seem to render as intended, screenshot below:

Code below:

extends Node2D

@export var noise_height_text : NoiseTexture2D
var noise = FastNoiseLite.new()

@onready var terrain: TileMapLayer = $Terrain

var width: float = 300
var height: float = 300

var terrain_rng = RandomNumberGenerator.new()

var sand_threshold: float = -0.3
var grass_threshold: float = sand_threshold + 0.07

# Called when the node enters the scene tree for the first time.
func _ready():
	generate_world()

func generate_world():
	#Sets the seed number to a random integer, allowing for new terrain to be generated
	noise.seed = randi()
	var cells1 = []
	var cells2 = []
	var cells3 = []
	for x in range (-width/2, width/2):
		for y in range (-height/2, height/2):
			#Gets noise value to determine which tile to place
			var noise_value: float = noise.get_noise_2d(x,y)
			#Uses noise value to place grass tile
			if noise_value >= grass_threshold:
				cells1.append(Vector2i(x, y))
			#Uses noice value to place sand tile
			elif noise_value > sand_threshold and noise_value < grass_threshold:
				cells2.append(Vector2i(x, y))
			#Uses noise value to place water tile
			elif noise_value <= sand_threshold:
				cells3.append(Vector2i(x, y))
	terrain.set_cells_terrain_connect(cells1, 0, 0)
	terrain.set_cells_terrain_connect(cells2, 0, 1)
	terrain.set_cells_terrain_connect(cells2, 0, 2)
	#Ensures the arrays are cleared, in case a new terrain needs to be generated.
	cells1.clear()
	cells2.clear()
	cells3.clear()

func _on_generate_world_pressed():
	_ready()