Inserting into a Table

Hello!
I want to have a table like this:

local Numbers = {
	[5366433] = 1,
	[1550005] = 2,
	[16433217] = 3,
	[309850] = 4,
	[43296] = 5,
}

I actually have like 500 lines in the table, I just shortened it for demonstration. I had to write the 500 lines manually. Which took too much time. Is it possible to get a table like this using table.insert so that I don’t have to do this manually?

Yes you can do table.insert in a for loop.

I think u misunderstood. If I put it in a for loop the numbers would be switched like this:

local Numbers = {
	[1] = 5366433,
	[2] = 1550005,
	[3] = 16433217,
	[4] = 309850,
	[5] = 43296,
}

My question is how to use table.insert to make the number in brackets 5366433

1 Like

Do you mean adding a new line into the table like this ?

Numbers[5366433] = 1

Oh definitely yes! I didn’t know the solution was this simple. Thank you very much for your help!

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.