Create tables for objects?

I’m trying to create a table for each part inside another table. This table will basically contain more parts.

I’ve been using Part:SetAttribute for true/false and number variables and even colors. Unfortunately roblox doesn’t let me do that for tables when that’s pretty much exactly what I need.

local function CreateTile(Pos)
	local Tile = Instance.new("Part")
	Tile.Name = "Tile"
	Tile.Size = Vector3.new(TileSize,TileSize,TileSize)
	Tile.Anchored = true
	Tile.Color = PreviousColor
	Tile.Material = Enum.Material.SmoothPlastic
	Tile.Parent = game.Workspace.Folder
	Tile.Position = Pos
	Tile:SetAttribute("Mine", false)
	Tile:SetAttribute("Flagged", false)
	Tile:SetAttribute("AdjacentMines", 0)
	Tile:SetAttribute("Revealed", false)
	Tile:SetAttribute("DefaultColor", PreviousColor)
	
	--***********Now I really need to also have a table for this tile which can also be easily accessed later in this code.
	Tile:SetAttribute("TileTable", {}) --this line doesn't work I get an error basically telling me this can't be used for array.
	
	
	table.insert(Tiles, Tile)
end

So what’s the best solution. Surely there is a way to assign a table here to the part that can be easily accessed later? Another solution I just came up while writing this: I could probably loop through the tiles table and create a table for each object in said table and the tables would align in a way that it would be pretty easy to find which table I need. Anyways I think that solution will work fine, but I’m still gonna post this question in case there’s a better way.

Roblox does not support TableValue in Attributes yet as you can see in this documentation.

For now, I believe that you need to JSONEncode the table into a StringValue then JSONDecode to obtain the TableValue.

The only solution I have ATM is basically creating a table for each part which is not very efficient.

You can store a table in a Part with the KeyValueService. As an example:
local p = Instance.new(‘Part’)
local t = {}
KeyValueService:SetAsync(‘t’, t)

And then you can get it back with:
local t = KeyValueService:GetAsync(‘t’)

Personally I’d do something like this

local parts = {}

--not sure what data you want in part Table so I’m just going to make a random table here.
local partTableExample = {"string", "second string"}

local testPart = Instance.new("Part")
parts[testPart] = partTableExample --store table

local getTab = parts[testPart] --retrieve table

That uses a dictionary to set/retrieve the table from the part.