Arrays (Want to search in all index one variable)

Greetings community, I have a little problem with this of the Arrays since I am new to it.

The problem is that I want to know if “n” is inside the Array, but I don’t know how to make it check index by index.

The script as such has to choose a variable from the table of some disasters that I have in my game, that variable is “n”, then it enters a checking system where it must detect if “n” is already in the Array, but there the problem, I don’t know how to tell the script to check index by index to see if the variable is there or not.

Script:

local Arrays = {}

function choose(tab)
	local n = math.random(1,#tab)
	
	print(n)
	if n == #Arrays then -------- Here's the problem, everything else works fine.
	  n = math.random(1,#tab)
	end
	if #Arrays == 10 then
		table.remove(Arrays, #Arrays)
		print(table.remove(Arrays, #Arrays) .. " A sido borrado una array ")
	end	
	
	
	local obj = tab[n]
	table.insert(Arrays, n)
	for index, value in ipairs(Arrays) do
		print(index, value)
	end
    return obj
end

If you have any questions, I can answer them with pleasure.

You check the contents of an array with something like this:

local testValue = ???
local foundAt = 0

for i = 1, #tableA do
if tableA[i] = testValue then
 foundAt = i
end
end

if foundAt == 0 then
print("number not found")
else
print("number found in record ".. foundAt)
end