If you mean you simply want to insert two values into one table, then you'd use table.insert. That way you can still utilize tabl[numhere].
local tabl = {}
table.insert(tabl, 'PartName')
table.insert(tabl, CFrame.new(0,0,0))
print(tabl[1], tabl[2])
Otherwise, if you wanted a table for each house, you'd need a different approach. Either you can use a dictionary type of style which is based on a key pair relationship or an array using table.insert.
A dictionary would be a key and a value. The key is the name of the table and the value is the table.
Example: ['Azarth'] = {PlaysROBLOX = true, SpeaksRussian = false}
local tabl = {}
tabl['house1'] = {
partName = 'Part1',
position = CFrame.new(0,0,0) }
print(tabl['house1'].position)
for i,v in pairs(tabl) do
print(i, v.position)
end
You could also insert a table within a table. This benefits you if you want the tables to be in the order (like a player-list) you inserted them as dictionaries are not when you try and return them in a for loop. Also beneficial if you want to nest other tables inside your main entry point.
local mainTable = {}
do
local entry = {}
entry.id = "house1"
entry.partName = 'Part1'
entry.position = CFrame.new(0,0,0)
table.insert(mainTable, entry)
end
for i = 1, #mainTable do
if mainTable[i].id == "house1" then
print(mainTable[i].position)
end
end
for i,v in pairs(mainTable) do
if v.id == "house1" then
print(v.position)
end
end
1 comment
what is bricks??