Removing objects from table in function

Nope.  The code I see there won’t behave as you have described.  You can easily test this.

Put some print statement in the function to see what it does and how your count progresses

local function updateLives( event ) print("entering updateLives(); numLives == ", numLives ) -- Remove Pip/Dot if( numLives \> 0 ) then display.remove( lives[numLives] ) numLives = numLives - 1 print("Removed a life; numLives == ", numLives ) end if( numLives \<= 0 ) then print("Bye! numLives == ", numLives ) print("------------------------\n") local options = { effect = "crossFade", time = 100 } composer.gotoScene( "levels.menu", options ) return end print("Continuing... numLives == ", numLives ) print("------------------------\n") end

@roaminggamer

It is a very strange situation for me I started reading on lua.org about the “loops” and it really should work as it is written, I do not know if using it within the “collision” event will alter some things.

18:08:54.316 level 1 18:08:57.786 right button tap 18:08:58.946 right button tap 18:08:59.106 right button tap 18:09:01.476 collision 18:09:01.476 entering updateLives(); numOfLives == 6 18:09:01.476 Removed a life; numOfLives == 5 18:09:01.956 collision 18:09:02.496 nil 18:09:02.496 nil 18:09:02.496 nil -------------------------------------------------------timers nil 18:09:02.496 nil 18:09:02.496 nil 18:09:02.496 nil 18:09:02.496 reload ---------------------------------------------------reload scene 18:09:03.237 level 1 18:09:11.066 right button tap 18:09:15.577 collision 18:09:15.577 entering updateLives(); numOfLives == 5 18:09:15.577 Removed a life; numOfLives == 4 18:09:16.618 nil 18:09:16.618 nil 18:09:16.618 nil 18:09:16.618 nil 18:09:16.618 nil 18:09:16.618 nil 18:09:16.618 reload 18:09:17.377 level 1 18:09:25.007 right button tap 18:09:25.306 right button tap 18:09:25.487 right button tap 18:09:27.987 collision 18:09:27.987 entering updateLives(); numOfLives == 4 18:09:27.987 Removed a life; numOfLives == 3 18:09:28.557 collision 18:09:29.017 nil 18:09:29.017 nil 18:09:29.017 nil 18:09:29.017 nil 18:09:29.017 nil 18:09:29.017 nil 18:09:29.017 reload 18:09:29.736 level 1 18:09:32.107 right button tap 18:09:32.327 right button tap 18:09:35.217 collision 18:09:35.217 entering updateLives(); numOfLives == 3 18:09:35.217 Removed a life; numOfLives == 2 18:09:36.257 nil 18:09:36.257 nil 18:09:36.257 nil 18:09:36.257 nil 18:09:36.257 nil 18:09:36.257 nil 18:09:36.257 reload 18:09:36.997 level 1 18:09:41.387 right button tap 18:09:41.527 right button tap 18:09:44.198 collision 18:09:44.198 entering updateLives(); numOfLives == 2 18:09:44.198 Removed a life; numOfLives == 1 18:09:45.257 nil 18:09:45.257 nil 18:09:45.257 nil 18:09:45.257 nil 18:09:45.257 nil 18:09:45.257 nil 18:09:45.257 reload 18:09:45.997 level 1 18:09:50.207 right button tap 18:09:50.389 right button tap 18:09:50.587 right button tap 18:09:53.218 collision 18:09:53.218 entering updateLives(); numOfLives == 1 18:09:53.218 Removed a life; numOfLives == 0 18:09:53.237 Bye! numLives == 0 18:09:53.237 ------------------------ 18:09:53.237 18:09:53.719 collision 18:09:54.240 nil 18:09:54.240 nil 18:09:54.240 nil 18:09:54.240 nil 18:09:54.240 nil 18:09:54.240 nil 18:09:54.240 reload ---------------------------------------------------W H Y ?? 18:09:54.996 level 1 ---------------------------------- IT'S SUPPOSED TO BE MAIN MENU

Investigate why numLives is higher than 3.   That is one big problem I see based on what you’ve said.

Also, examine where updateLives() is being triggered and work back from there.

Finally, I think you need to have someone look at your game and walk through that bit with you.  There is more to this scene/file and I’m sure there is another factor here.