I keep getting this error and I can’t fix it . I’ve been looking on here and stack overflow for answer but none help me . I keep getting this error :
attempt to call method ‘removeSelf’ (a nil value)
It started when I was trying to add a reset button to my code . When I click the button it runs the startGame() function . Please help me
function startGame(event) titleScreenGroup:removeSelf() appodeal.show("interstitial") --\<-------- move this to scene:show()'s "did" phase resetScore() -- in the case that this is a rematch placePlayerOnePaddle() placePlayerTwoPaddle() placePuck(puckAvalLocation.center) Runtime:addEventListener( "postCollision", onPostCollision ) Runtime:addEventListener( "collision", onCollision ) end function resetScore() p1ScoreText.text = "0" p2ScoreText.text = "0" end local function gameRestart(event) if ("ended" == event.phase) then --code here when touch begin startGame() end end function setUpGroundGraphics() local graphic = display.newImageRect( "bg.png", 768, 1024 ) graphic.x = display.contentWidth / 2 graphic.y = display.contentHeight / 2 local graphic = display.newImageRect( "score.png", 122, 144 ) graphic.x = topLeft.x + 90 graphic.y = display.contentHeight / 2 graphic = display.newImageRect( "centerLine.png", 768, 9 ) graphic.x = display.contentWidth / 2 graphic.y = display.contentHeight / 2 graphic = display.newImageRect( "centerCircle.png", 198, 198 ) graphic.x = display.contentWidth / 2 graphic.y = display.contentHeight / 2 -- top goal line graphic = display.newImageRect( "goalLine.png", 497, 203 ) graphic.x = display.contentWidth / 2 graphic.y = topLeft.y + wallThickness \* 2 + 70 -- bottom goal line graphic = display.newImageRect( "goalLine.png", 497, 203 ) graphic.x = display.contentWidth / 2 graphic.y = bottomRight.y - wallThickness \* 2 -70 graphic.rotation = 180 resetButton = display.newImageRect( "reset.png", 508, 224 ) resetButton.x = display.contentWidth / 4.1 resetButton.y = display.contentHeight - display.contentHeight / 2.5 resetButton:scale( 0.4, 0.4 ) resetButton:addEventListener("touch", startGame) end