attempt to index a nil value

im having this error when i change icon of the button

module(...,package.seeall ) function new( ) local localGroup = display.newGroup( ) -- Require the widget library local widget = require( "widget" ) local background = display.newImageRect("bkg.jpg",480, 800) localGroup :insert( background ) background.x = display.contentCenterX background.y = display.contentCenterY local button1 = widget.newButton { defaultFile = "button\_herittage.png", onPress = buttonPress, } button1.x, button1.y = 248, 180 localGroup :insert( button1) local function buttonPress( event ) if event.phase == "ended" then director:changeScene("tiga","moveFromRight",400) end end button1:addEventListener( "touch", buttonPress ) local button2 = widget.newButton { defaultFile = "button\_food.png", onPress = buttonPress, } button2.x, button2.y = 257, 400 localGroup :insert( button2 ) local function buttonPress( event ) if event.phase == "ended" then director:changeScene("empat","moveFromRight",400) end end button2:addEventListener( "touch", buttonPress ) local button3 = widget.newButton { defaultFile = "button\_accomodation.png", onPress = buttonPress, } button3.x, button3.y = 266, 650 localGroup :insert( button3) local function buttonPress( event ) if event.phase == "ended" then director:changeScene("lima","moveFromRight",400) end end button3:addEventListener( "touch", buttonPress ) local button4 = widget.newButton { defaultFile = "button\_transport.png", onPress = buttonPress, } button4.x, button4.y = 275, 900 localGroup :insert( button4) local function buttonPress( event ) if event.phase == "ended" then director:changeScene("enam","moveFromRight",400) end end button4:addEventListener( "touch", buttonPress ) local button5 = widget.newButton { defaultFile = "button\_maps.png", onPress = buttonPress, } button5.x, button5.y = 275, 900 localGroup :insert( button4) local function buttonPress( event ) if event.phase == "ended" then director:changeScene("tujuh","moveFromRight",400) end end button5:addEventListener( "touch", buttonPress ) return localGroup -- body end

Apart from anything else that may be an issue, you’re using the director class, yes?

That is very, very old and won’t work with Corona ‘graphics 2.0’, because, amongst other things, it uses named anchors (“topLeft”) rather than anchorX, anchorY values.

Unless you want to update the whole of the class to work with modern Corona, I would suggest you jump to the Composer library.

https://docs.coronalabs.com/daily/guide/system/composer/index.html

Also, you shouldn’t really be using module(…,package.seeall ) these days!

p.s… when you’ve got round those issues, the next is … you simply can’t have 5 local functions with exactly the same name in the same module, laying it out as you have (buttonPress)

Apart from anything else that may be an issue, you’re using the director class, yes?

That is very, very old and won’t work with Corona ‘graphics 2.0’, because, amongst other things, it uses named anchors (“topLeft”) rather than anchorX, anchorY values.

Unless you want to update the whole of the class to work with modern Corona, I would suggest you jump to the Composer library.

https://docs.coronalabs.com/daily/guide/system/composer/index.html

Also, you shouldn’t really be using module(…,package.seeall ) these days!

p.s… when you’ve got round those issues, the next is … you simply can’t have 5 local functions with exactly the same name in the same module, laying it out as you have (buttonPress)