So, I’m just fiddling around with the for i, v in pairs loop atm. I am trying to have it check to see if each value in the array is higher than the one before it, and if it is set it as the highest. However, it prints 0. Why is that? Interestingly, I tried printing inside the if statement and the string printed successfully.
local myTable = {1, 10, 8, 7}
local highest = 0
for i, v in pairs(myTable)do
if v > highest then
v = highest
end
end
print(highest)