There has been a sudden bug that appeared in my Saving System module:

It seems that the error is from table.insert() needing the 2nd argument to be a number to determine its position in the table. But adding the 2nd argument is purely optional and should be handled by Roblox automatically to determine the position of the item inserted. Has anyone experienced this issue?
I haven’t done any significant changes to my code in a couple of months so this bug came out of nowhere.
3 Likes
table.insert() not Table.insert() is causing your issue.
If you could provide a snippet of the code, that would be useful.
1 Like
Note that I haven’t changed the code in months so it’s been working until now. Also the title just says Table.insert() because I just have a habit of capitalizing the first word in a title.

3 Likes
table.insert(Files, #Files + 1, SavingFileData:GetAsync(Data))
This will only work if the table is an array.
1 Like
I have already done this solution and it does not fix the problem. Also Roblox’s script analysis advises against doing this as there’s no point.

3 Likes
table.insert() only works with arrays and not dictionaries.
If you need to insert an item into a dictionary you will need to do the following.
local key = "somekey"
local val = "someval"
local tableDict = {}
tableDict.key = val
It’s an array not a dictionary.

3 Likes
Have you tried Files[i] = SavingFileData:GetAsync(Data)
instead?
That was actually my original solution. I’m just wondering why table.insert() suddenly needs the position argument now.
3 Likes
I’m aware of how table.insert() usually works, personally I’ve never seen this error before, please report back here once you’ve tested the aforementioned solution.
I already tested the solution, no errors. As mentioned before I was just wondering why table.insert() needs a position argument.
3 Likes
What does SavingFileData:GetAsync(Data)
return? Print it in the output.
GetAsync function calls always return a tuple.
If you’ve looked at the image above it was a string.
3 Likes
That is the problem. Put it in an array:
{SavingFileData:GetAsync(Data)}
You have to realize, I have not done ANY changes to the script for many months but now it’s just suddenly breaking.
3 Likes
I know it may sound weird but try to rename your variable to something else besides of Files
For testing just call it _Files or just files (anything besides Files)
If you want to retain the tuple in its returned form then simply stick with the solution I posted above.
Files[i] = SavingFileData:GetAsync(Data)
It achieves the same desired result as table.insert() would.
1 Like
Files isn’t a reserved keyword.
Look I already told you, I’ve used that solution and it works. As mentioned many times before, I’m just wondering why table.insert() needs a position argument when it’s optional.
3 Likes