Save in the next position in a Table

Hi!

I want to do a table with questions that the user do.

When te user save the first question, the code must to save in the first position of the table. Then in the second question too and consecutively.

FOR EXAMPLE, I THOUGHT THAT WITH THIS CODE CAN WORK;

local loadsave = require(“loadsave”)

fuction save(event)

  myTable.question.[x] = question

  x = x+1

end

loadsave.saveTable(myTable, “myTable.json”)

so if x = 1 save in first position of the table, if x = 2 the second etc.

Can u help me?

THANKS

PD: Sorry for my bad english. Im from Argentina!!!

Remove the dot in front of [x]:

[lua]myTable.question[x][/lua]

The structure of your table isn’t clear but if it’s number-indexed and only contains those questions, you probably don’t need the other dot too:

[lua]

fuction save(event)

  myTable[x] = question

  x = x+1

end

[/lua]

Also, a standard way of appending to a table would be:

myTable[#myTable + 1] = “whatever”

Remove the dot in front of [x]:

[lua]myTable.question[x][/lua]

The structure of your table isn’t clear but if it’s number-indexed and only contains those questions, you probably don’t need the other dot too:

[lua]

fuction save(event)

  myTable[x] = question

  x = x+1

end

[/lua]

Also, a standard way of appending to a table would be:

myTable[#myTable + 1] = “whatever”