Could not change tilemap atlas texture region

Godot Version

4.6.1.stable

Question

I’m making a mario-maker inspired game, and I already got game themes working. One of the game themes is 64x64, while the rest are 16x16. I’m trying to update the tilemap to use 64x64 when the 64x64 theme is selected, but it always errors out. If I don’t change the atlas or the tile map size and texture region to 64x64, the tiles always appear really tiny when switching

func _changeGameTheme(game : int) → void:
#game stands for gameID
#chage texture
var texture = load(“res://Asset/TileSets/assets/” + str(game) + “-0.png”)
tilemap.tile_set.get_source(0).texture = texture

#check for upscaled theme
#19519 is the id of the 64x64 theme
if game == 19519:
	#if it is upscaled theme, update texture...
	tilemap.tile_set.get_source(0).texture_region = Vector2i(64, 64)
	tilemap.tile_set.tile_size = Vector2i(64, 64)
	tilemap.scale = Vector2(0.25, 0.25)
else:
	#else if it is not, change it back to normal
	tilemap.tile_set.get_source(0).texture_region = Vector2i(16, 16)
	tilemap.tile_set.tile_size = Vector2i(16, 16)
	tilemap.scale = Vector2(1, 1)

Just change the scale of the TileMapLayer to 4.0 when the 16x16 tiles are selected.

That doesn’t work

Hmmm it worked for me when I needed to make some odd-sized tiles match 128x128 tiles. Just scaled them up.