How do I make dictionaries like this with code?
You could try and use table.insert()
, adding blank dictionaries and then filling them with information:
local dict = {}
table.insert(dict, {})
table.insert(dict, "hi")
table.insert(dict[1], "info")
table.insert(dict[1], {})
print(dict)
--expected output: {{"info", {}}, "hi"}
1 Like
Simply define each key followed by an equal sign and add a value, remembering to separate each key-value duo with a comma.
Example:
local Dictionary = {
SectionA = {
Value1 = "Hello",
Value2 = "Goodbye",
},
SectionB = {
Vaule1 = "Good morning",
Value2 = "Goodnight",
}
}
print(Dictionary.SectionA["Value1"]) -- Output: Hello
print(Dictionary.SectionB["Value2"]) -- Output: Goodnight
You can learn more on them here:
https://developer.roblox.com/en-us/articles/Table
1 Like
Found out u could simply do, thanks anyways!
for i, part in modelPart:GetDescendants() do
if part:IsA("Part") then
local properties = {}
properties["Type"] = "Part"
properties["Color"] = tostring(part.Color)
properties["Material"] = tostring(part.Material)
properties["CFrame"] = tostring(part.CFrame)
properties["Size"] = tostring(part.Size)
properties["Reflectance"] = part.Reflectance
properties["Shape"] = tostring(part.Shape)
partsInModel[part.Name] = properties
end
end