Storing unique data in a tile

Godot Version

4.2.2

Question

How do I add unique data per tile in a tilemap. Im working on a game where you can break and place tiles and while placing is straightforward breaking them has been giving me an issue. Each block type in the game has a unique health so wood and stone dont take the same amount of hits to break. But I cant even figure out a way to store health without it effecting every tile of that type.

If anyone knows what to do, thanks.

Code for breaking blocks (Not working)

func _ready():
	getGridPos()
	player = get_parent()
	tileGrid = player.get_parent().find_child("Walls")
	
	for i in tileGrid.get_used_cells(0):
		tileDataGrid[i] = 4
	print(tileDataGrid.size())

func breakBlock():
	var usedTool = player.selectedItem.relatedTool
	var dataAtPos = tileGrid.get_cell_tile_data(0, gridPos)
	var blockAtPos : Block
	
	if (dataAtPos):
		blockAtPos = dataAtPos.get_custom_data("BlockData")
	var miningDmg = player.selectedItem.relatedTool.miningDmg
	if (blockAtPos && miningDmg >= blockAtPos.minDmg && Input.is_action_just_pressed("Action")):
		print(tileDataGrid.get(tileGrid.local_to_map(global_position)))

Add an @export to the variable inside your blocks?

class_name Block extends Node

@export var Health : int = 100

Or maybe add the block to an autoload database? Then assign the IDs on creation? So you have something to reference?

class_name Block extends Node

@export var Item_ID : String

var Block_Check : bool :
	get : return Database.Block_List[Item_ID]
	set(value) : Database.Block_List[Item_ID] = value

There is a property called metadata for custom storage per node basis. Can you use that?

The problem is the blocks are tiles in a tilemap. So I dont think that would work.

Each block is a resource. Sorry for not specifying earlier. Ive tried adding unique values and attaching classes to the resource but it applies for every instance of it no matter what I do.

https://www.reddit.com/r/godot/comments/17g7lpf/unique_instances_of_resources/