lua last item in table

-- Assuming 'myTable' is the table in question
local lastItem

-- Check if the table is not empty
if next(myTable) ~= nil then
  -- Iterate over the table
  for _, value in pairs(myTable) do
    -- Update 'lastItem' with the current value
    lastItem = value
  end
end

-- 'lastItem' now holds the last element in the table, or nil if the table is empty