I figured it out and this is how the function works.
The function loops threw all the Vector2i’s in an array that you provide it, then it changes the corresponding cells to a specific tile type that you set.
If you provide it with too many Vector2i’s as I did it will not run or at least run slowly, so if this is a problem you can split your array of Vector2i’s into smaller chunks and run them in small groups.
Also, don’t forget to set up your tilemap/terrain in the editor or it will not work properly.
set_cells_terrain_connect(a,b,c,d,e)
a: layer: int, this sets the layer to draw to.
b: cells: array of Vector2i, add all the cells you wish to change on your tilemap
c: terrain_set: int, This selects the set of tiles you wish to use.
d: terrain: int, This selects the tile in the terrain_set you wish to draw.
e: ignore_empty_terrains: bool = true, (I'm not really sure I have not played with this but at a guess, I would say it has to do with drawing edges when next to empty cells)(let me know if I'm wrong)
Eg:
var list_of_tiles = [Vector2i(5,6),Vector2i(5,7),Vector2i(6,6)]
$TileMap.set_cells_terrain_connect(0, list_of_tiles, 0, 1,true)