Get_cell_tile_data return the false information.... return the random value null/Tile07548 but those are wrong

var mouse_position = get_global_mouse_position()
var current_tile = map_node.get_node(“TowerExclusion”).local_to_map(mouse_position)
var tile_position = map_node.get_node(“TowerExclusion”).map_to_local(current_tile)
var data = map_node.get_node(“TowerExclusion”).get_cell_tile_data(0, current_tile)

	if data:
		print("CELL EMPTY")
		get_node("UI").update_tower_preview(tile_position, Color.RED)
		build_valid = true
		build_location = tile_position
		print("CELL OCCUPIED")
		get_node("UI").update_tower_preview(tile_position, Color.RED)
		build_valid = false

Your TileMap node probably isn’t on the origin and thus its offset from the global origin. To make sure the positions correlate you will have to turn the mouse_position to local position relative to the TileMap node.
So after you get the var mouse_position you need to convert it to local position relative to the TileMap:

var local_mouse = map_node.get_node("TowerExclusion").to_local(mouse_position)

then pass the new local_mouse variable through the local_to_map() function of your TileMap instead of mouse_position

1 Like

Thank you! I’m not op, but this helped me immensely.