I have this example code:
for i in 8 do
print(i)
end
It returns the error “attempt to iterate over a number value”
I have this example code:
for i in 8 do
print(i)
end
It returns the error “attempt to iterate over a number value”
for i = 1, 8 do print(i) end
To add, the way a numerical for loop works like this:
for index = startValue, endValue, incrementValue do
-- do stuff
end
-- Side note here: incrementValue is 1 on default, so unless you specify, it's going to increment 1
--@ examples:
for i = 1,10 do
print(i) -- 1,2,3,4...
end
for i = 10,1,-1 do
print(i) -- 10,9,8,7...
end
for i = 10,1 do
print(i) -- doesn't work because it cannot start from 10 and increment positively to 1
end
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.