Dictionary indexing returns "StringNameStringName" instead of "StringName"?

Hi everyone!

I was making a building system earlier, and I came across an issue where the script will throw an error like this:
SaveSlotSaveSlot2 is not a member of BuildsFolder

Here’s the code involved:

buildsFolder["SaveSlot"..tostring(i)]

(Note, i is in a for loop, something like this:)

for i, saveSlot in pairs(data) do

-- saveSlot is a table, so I can't use that

I have ZERO clue on why this happens, please help!

In the case of dictionaries, the index is the key of the value, and is not always a number like an array.

Okay, I’ll see if that works (maybe using a variable instead of straight up indexing it?)

In your specific case, it looks like you’d be able to just remove the “SaveSlot” concatenation before the index when indexing the builds folder, since the index itself already is “SaveSlot” with the number at the end.

Wow! I never knew that!

Thanks so much man, really helped! :^)