Problem removing obj in array and event listeners attached

My apologies Primoz I was not at my computer so therefore was unable to provide a readout of the error message, below is the error I receive when running in.

 --create the BUG's as random images of 3 different BUGS local bugImages = {"bee.png","beetle.png", "wasp.png"} local bug[TotalBugs] = display.newImage(bugImages[math.random (#bugImages)]) --bug[TotalBugs] = display.newImage("bee.png", 35,35) --setup tab listener bug[TotalBugs]:addEventListener( "tap", bugKilled ) --setup where bug will spawn bug[TotalBugs].x = startingX bug[TotalBugs].y = startingY --physics.addBody( bug[TotalBugs], "dynamic", { isSensor=true, radius=35} ) bug[TotalBugs].name = "enemyBug" group:insert(bug[TotalBugs])

File: error loading module 'gameScene' from file '/Users/danny\_roerring/Dropbox/Documents/Game Development - Roedan Games/\_GAMES/Bug Splatter (temp) - GAME/gameScene.lua' Error loading module 'gameScene' from file '/Users/danny\_roerring/Dropbox/Documents/Game Development - Roedan Games/\_GAMES/Bug Splatter (temp) - GAME/gameScene.lua': ...velopment - Roedan Games/\_GAMES/Bug Splatter (temp) - GAME/gameScene.lua:151: unexpected symbol near '[' stack traceback: [C]: ? [C]: in function 'error' ?: in function 'gotoScene' ...ames/\_GAMES/Bug Splatter (temp) - GAME/menuScene.lua:32: in function '\_onRelease' ?: in function '?' ?: in function \<?:1091\> ?: in function \<?:218\>

The problem is the local directive

local bug[TotalBugs]= display.newImage(bugImages[math.random (#bugImages)])

you can not make a table index local only the table can be made local where it si declared.

This will work:

bug[TotalBugs]= display.newImage(bugImages[math.random (#bugImages)])

OMG your correct, can’t believe I totally overlooked that and didn’t realise. Thanks for seeing it for me. Always good having another pair of eyes. Will correct this once I get home and re-test.