Table script not working

I am trying to make a script that can take a table with tons of values, and put the last 10 values of that table into a new table. My code is below. Anyone know why it won’t work?

Edit: I am getting no errors, and the new table ends up having more than 10 values.

for x, v in ipairs(infoTable) do
if x >= #infoTable - 10 then
table.insert(newTable, 1, v)
end
end

Use table.move instead. It’s pretty performant and easy to use.

table.move(sourceTable, math.max(1, #sourceTable - 10), #sourceTable, 1, destinationTable)

Read as: move elements from 10 back from the total number of elements in the source elements to the total number of elements in the source table to index 1 and counting of the destination table.

Thank you! Let me try this, I will come back with what the results are.