The iteration variable in a
for lop should be isolated between each iteration. I ran the following test as proof.
Lua Code:
local t={};
for i=1,5 do
t[i]=function() print(i); end
end
for _,f in ipairs(t) do f(); end
This prints the following output.
In conclusion, something in your code is contaminating the variable in your
for loop. Without being able to look through all of your code, there's no way to tell what's going on exactly.