When I write myvar[2]=15 it gives me an error.

Is there a way to do a similar task without having to type myvar = {myvar[1], 15, myvar[3]}

I don’t get an error when I run this, so you must not be declaring your table first.

function setup()

okay woops didn’t notice that.
(how do you mark a post as solved?)

You can edit the original post and put Solved, or I can do it for you.