What would be the best way to organize this table for player characters?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    Find a unique, sensible key for key-value pairs.
  2. What is the issue?
    In my game, a player essentially has an “inventory” of characters stored as tables in a datastore. I am struggling to find a unique identifier for each character that makes sense as a table key to access each character table while preserving the ability to name two separate characters the same name, or give different characters the same attributes. In short, I need something easily accessible that is not the name of the player’s character, so the player can make multiple different characters with the same name and the different same-named characters can be stored as separate tables in the datastore.

To further illustrate what I mean, here is the template table for a player’s character:

		["CharacterName"] = {
			
		stats = {
			TowerHealth = 120,
			TowerAttack = 0,
			TowerSpeed = 0,
			TowerRange = 0,
				
			CharHealth = 0,
			CharAttack = 0,
			CharDefense = 0,
			CharCastSpeed = 0,
		},
			
		Level = 1,
		Experience = 0,
		Class = "Warrior",
		CharacterNumber = 1,
		Name = "Name",
		}	
	}

Instead of using the character’s name, what would be a clever unique key to give each value in an array of these tables? Ideally I would be able to access a specific character table using the key, instead of having to loop over the entire array of tables to find the desired table I need.

What solutions have you tried so far?
I considered using tick() as the key for each table value, but accessing the array without looping through every time is impossible doing so, even though tick() will give a unique identifier every time a character is created regardless.

You can use the player’s userid to store the data as it is unqiue for every player which is often what most games do as if you use a player name it could cause the player to lose there data if they change there name. So go wiht the userid as a data key.