Set a tile using autotile in Gdscript

Godot Version

Godot 4.4 Stable

Question

Is there a way to set a tile from an Autotile in a TileMap Layer using Gdscript? This is my current code(It doesn’t work with Autotile):

func _SetBlock(Pos):
	var LocalPos = Map.local_to_map(Pos)
	print(LocalPos)
	Map.set_cell(LocalPos, MapSourceId, AtlasCoord)

I want to do this for an in-game level editor

You’ll need to use TileMapLayer.set_cells_terrain_connect() or TileMapLayer.set_cells_terrain_path() for that.