I'm working to create a dungeon roguelike currently using rectangular rooms on a randomly generated map. My map is generated as a 2D array of structs and it's working properly as far as I can tell. My question is, how can I assign the tiles at runtime into the game world?
This is what I'm currently trying:

	TileMap mainMap = GetNode<TileMap>("Dungeon");
	TileMap backMap = GetNode<TileMap>("BackMap"); // background tilemap, should cover all spots on the grid
	for (int r = 0; r < numRows; r++) {
		for (int c = 0; c < numCols; c++) {
			backMap.SetCell(0, new Vector2I((r + 1)*1260, (c + 1)*720), 0);
			if (gridMap[r,c].active) {
				mainMap.SetCell(1, new Vector2I((r + 1)*1152,(c + 1)*648), 0);
			}
		}
	}
}

The result of this code is currently three errors relating to getNode referencing issues. The previous set of errors I got was caused something along the lines of "These cells are already occupied", I fixed this by moving the world generation to its own scene and making that scene a child of the main scene.

This is how I did it. However, all of that code is for godot 3.x, so it needs updating to 4.x.

Edit: Unfortunately, I don't know much about c# or godot 4.x, so I can't give you specifics. Your question is also a little vague, so you may not get much help unless you can phrase it better. Paste the text of your errors, etc.