Why when I change data from the dictionary of data does it change data for everything?

Godot Version

4.7.2

Question

I made this script that gets all of the used tiles in a tilemaplayer, assigns them each data with the key as their coordinates on the tilemaplayer, but whenever tryharvest is called it changes the harvestable property for all cells, not just the one at the coordinate, how would I fix this? All of the parameters given in tryharvest from where its called is good and when spawnitem is called it spawns at the correct place, anything thats set to null is a placeholder I’m testing with only the tree data currently.

extends TileMapLayer

@onready var mapground = $"../MapGround"
@onready var itemmanager = $"../../ItemManager"

var allplantdata = {}

#Name, Hitpoints, Harvestable, HarvestItem, HarvestAmount, HarvestDifficulty, HarvestProgress
var plantdatas = {
	"Tree" = ["Tree", 50, {"Harvestable" = true}, "res://Items/Food/Apple.tscn", Vector2i(0, 2), 1.5, 0.0], 
	"TATB" = ["Thorns and The Brabble", 15, {"Harvestable" = false}, null, null, 0.75, 0.0],
	"Blue Chalksticks" = ["Blue Chalksticks", 15, {"Harvestable" = false}, null, null, 0.75, 0.0],
	"Pamwheat" = ["Pamwheat", 15, {"Harvestable" = false}, null, null, 0.75, 0.0]
	}

func _on_map_ground_mapgendone() -> void:
	for cell in get_used_cells():
		initsetplantdata(cell)
	
func initsetplantdata(cell):
	if get_cell_source_id(cell) == -1: return
	allplantdata.set(cell, plantdatas.get(get_cell_tile_data(cell).get_custom_data("Name"))) 

func getplantdata(coords):
	if allplantdata.has(coords):
		return allplantdata.get(coords)
	else:
		return -1

func tryharvest(amount : float, cellposition) -> bool:
	var celldata = getplantdata(cellposition)

	celldata[6] += amount + 0.25/celldata[5]
	if celldata[6] >= 1:
		celldata[2].set("Harvestable", false)
		allplantdata.set(cellposition, celldata)
		itemmanager.spawnitembyname(celldata[3], randi_range(celldata[4].x, celldata[4].y), cellposition)
		return true
	else:
		return false

Arrays and dictionaries are always passed by reference. If you assign one of the arrays you hold in plantdatas as a value to multiple elements in allplantdata, they will all point to the same array object. If you want each element to hold a unique copy of that array, you need to duplicate the array. If that array holds more arrays or dictionaries, you need to make a deep duplicate. See duplicate() and duplicate_deep() in the reference page for Array in Godot’s docs.

Thank you, this worked very well.