String formatting and for loop

This is probably very easy to solve but I haven’t figure it out yet. Can somebody help me with how to achieve this:

I have 18 game levels and I want to check the player has got to max. score of 9000 in the particular level and if so for how many levels they did achieve max score.

my table is from myTable.score01 to myTable.score18

but the code below does not work. What should be the right format after “if” ?

local count = 0 for i = 1, 18 do local exponent = string.format( "%02d", i ) if myTable.score .. exponent == 9000 then count = count + 1 print("count " .. count) end end

Try myTable[“score”…exponent]

Works exactly the way I wanted. Thanks a lot for very fast response.

Try myTable[“score”…exponent]

Works exactly the way I wanted. Thanks a lot for very fast response.