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.