I would like to access a dictionary filled with information that is also in another dictionary, but im not sure how to access the dictionary inside the dictionary.
here is my attempt:
local building = {}
local partinfo = {
name = script.Parent.Name
}
building["partinfo"] = {partinfo}
local part = building["partinfo"]
local info = part["name"]
print(info)
when I print “info”, it prints nil when its expected to print “Part” as that’s the name inside the dictionary “partinfo”.
local building = {}
local partinfo = {
name = script.Parent.Name
}
building["partinfo"] = {partinfo}
local part = building["partinfo"]
local info = part[1]["name"]
print(info)
The problem is that you put the table in another table (array specifically), and you’d need to index it properly.
The table’s format would look like this:
building = {
["partinfo"] = {
{
name = script.Parent.Name
}
}
}
Also this entire script is quite a mess, it can be easily reduced to something like this
local building = {}
building.partinfo = {name = script.Parent.Name}
local part = building.partinfo --this is the part
local name = part.Name --this is the name info
print(name)
oh ok, im trying to setup datastores that use dictionaries to index information about a model full of parts, so Im learning as much about tables and dictionaries as I can.