Table.insert() Suddenly Needing a Position Argument

Probably an internal issue. You can report it to either @Bug-Support or #bug-reports:engine-bugs.

Edit: reviewed the documentation for GetAsync and it seems like DataStores V2 has been released as GetAsync returns a tuple now instead of a single value.

2 Likes

Relax, could you wrap the :GetAsync call with a print function? Then show the console log.

It is because GetAsync returns a tuple, that means, it returns multiple values not one.

So when you put it in table.insert it treats the first value in the tuple as the position, and the second value as the value, which will obviously not work.

That’s the only difference I’ve noticed. He said it worked in the past and now doesn’t, common sense makes it sound that it is but he just needs to test and confirm

table.insert(Files, tostring(SavingFileData:GetAsync(Data)))
1 Like

There is no point in doing this as GetAsync() already returned a string if you looked at the first image.

image

Also if you’re wondering, it just returns a bunch of jumbled serialized items in a string.

3 Likes

The :GetAsync() call returns multiple values, which means that the first of its returned values ends up being passed as the second argument to call to the table.insert() function and the second of its returned values ends up being passed as the third argument and so on. By converting the entire returned tuple into a single string, the call to table.insert() will be valid again.

FYI: You can wrap function calls in () to limit the return count to 1 value. Example for this case would be table.insert(Files, (SavingFileData:GetAsync(Data))

This would then discard all of the returned values after the first value. In this case I assume the original poster wishes to insert all values into the table.

…which is not what the original poster is intending to do since he is only trying to insert the actual data and not the other information returned by GetAsync (new feature in GetAsync added after the poster made his code).

1 Like

It’s still best to keep that additional data for archival purposes. Since it contains information pertaining to the datastore ā€œtransactionā€ so to speak.

You have literally been on this forum for the past 8 hours distributing information that is half wrong please shut up

3 Likes

Please inform me which information is wrong & I’ll fix it post haste.