Hello, I’m familiarizing myself with Roblox studio and I’ve hit a wall and don’t know what to do. I’ve looked for a long and haven’t found a solution, or perhaps I’m just not looking hard enough.
So what I’m trying to do is basically loop through the array1 and insert each key and values and how would you go on renaming them with the Name value?
for i, v in pairs(array1) do
table.insert(tests, v)
end
You shouldn’t be using table.insert because “tests” is a dictionary and table.insert is only really useful for arrays since it appends a value at the last numerical index (unless you specify an index to insert at).
You can just set the value of the key at the current iteration of the for loop to the table containing “Name” and “Description” directly, e.g.:
tests[i] = v
It’s also nice to give your variables meaningful names so you don’t get lost in your code later on
for foodItem, foodData in pairs(array1) do
tests[foodItem] = foodData
end