Any way to seperate values on a table inserted into for loop?

I have a for loop and am inserting v into it, but my problem is I can’t seem to seperate the two values

	 for i, v in pairs(plots:GetChildren()) do
		if not v:FindFirstChildWhichIsA("StringValue") then
			table.insert(t, 1, v) --- prints both values of v, which I want the value seperated into [1] or how many are in the table.

change t to i

you spelt it wrong

You can just do

table.insert(t,v)

and it’ll insert it at the end of the list. unless you want it to be inserted at the beginning then keep 1 as the second argument.

Another thing, if you want “sperate values” you can also insert a table of tables so do something like

table.insert(t,{v = i})

or something along those lines. But if the value is the same thing as another it’ll just be overwritten.

If you give us an example use case i might be able to help better as i have no idea what your intention is or how you would like to structure this.

t is the table

thus, he spelt it right

2 Likes

Sorry for the misunderstanding, I’ll try clear this up a bit. I tried both of your methods but I ran into a problem.

I am trying to basically separate one value from another, for example

 for i, v in pairs(plots:GetChildren()) do
		if not v:FindFirstChildWhichIsA("StringValue") then
			table.insert(t, v) --- v has two values, i'll reference them as plot3 and plot4.
			print(t[1][2]) --- what I am wanting is for slot 1 in the table to have value of plot3, and slot 2 as plot4. the problem I'm having is that the two values are combined into one slot.

I tried both of your methods, first one the problem is, if I do that and unpack the table, it looks like this:
(using plot3 and plot4 to reference the two objects inside)

 plot3
  plot3 plot4
  plot3 plot4 plot3
  plot3 plot4 plot3 plot4

The second suggestion I tried, however I unpacked it and it printed the table id.

Hope this clears everything up.

Hi sorry for taking so long to respond,

If i understand you dilemma correctly, you want to have the v array which contains "plot3", "plot4" to be inside of t so when you do t[1] you get "plot3" and when you do t[2] you get "plot4", if that’s the case then you can simply set the t to v since v is already an array. So simply do

t = v