nevermind, I should have made my post more clear, I couldn’t make my key inside of dictionary have only one value, because I need both name and position of an object inside of key, which happens to be automatically done by other lines of the script.
I tried table.pack(dictionary.A)[2] in dictionary but it somehow gives nil value… its not because other lines of code is giving nil because when I print directly the table, it gives both of value that is not nil
I don’t quite understand, @AC_Starmarine 's answer should have been good enough.
local dictionary = {
["Lemon"] = CFrame.new(1, 2, 3), -- separate each line with a ","
["Apple"] = CFrame.new(21, 42,69, 420,999)
}
You can then do:
for i, v in next, dictionary do
print(i) -- Name
print(v) -- CFrame
end
If you would like more control over the dictionary, like not having to use for i, v in next every time just to get the name, then you can order your dictionary like this instead:
Then use dictionary[1][1] for “Lemon” name, dictionary[1][2] for lemon CFrame, dictionary[2][1] for “Apple” name, and dictionary[2][2] for apple CFrame.
There was a } at the end of his initial post, so I assumed he accidentally cut off his table when posting. If it was a tuple, then yes, you would use table.pack