· 5 years ago · Nov 05, 2020, 05:30 PM
1local function DictionaryComponents(Dictionary: Dictionary, Parent: string, Descendants: Dictionary?) --> Nil
2 for index, value in pairs(Dictionary) do
3 local valueType = typeof(value)
4
5 if valueType == "table" then
6 local valueParent = Descendants and Descendants[index]
7
8 -- If the object does not exist then lets create a subfolder (because tables are folders)
9 if not valueParent then
10 local folder = Make("Folder", {Name = index, Parent = Parent})
11 DictionaryComponents(value, folder) -- Folder is going to be the parent
12
13 continue
14 end
15
16 -- If the object exists then
17 local createable_instances = {}
18
19
20 for objName, objValue in pairs(value) do
21 -- if the object already exists
22
23 local Object = valueParent:FindFirstChild(objName)
24
25 if Object then
26 local objChildren = Object:GetChildren()
27
28 for _, subObject in pairs(objChildren) do
29 if not Object:FindFirstChild(subObject.Name) then
30 continue
31 end
32
33 if subObjectv:IsA("Folder") then
34 continue
35 end
36
37 subObject.Value = objValue[subObject.Name]
38 end
39
40 continue
41 end
42
43 createable_instances[objName] = objValue
44 end
45
46 DictionaryComponents(createable_instances, valueParent)
47
48 continue
49 end
50
51 -- If the typeof value is not "table" then lets create a value
52 local Object = Parent:FindFirstChild(index)
53
54 if Object then
55 Object.Value = value
56
57 continue
58 end
59
60 local List = {Name = index, Value = value, Parent = Parent}
61 Make(PossibleTypes[valueType], List)
62 end
63end