Bad argument #-2 to 'insert' on storyboard.gotoScene

Personnel,'m with problems in storyboard, is giving me the error:

File: bad argument #-2 to ‘insert’ (Proxy expected, got nil)

Bad argument #-2 to ‘insert’ (Proxy expected, got nil)

stack traceback:

    [C]: ?

    [C]: in function ‘insert’

    ?: in function ‘?’

    ?: in function ‘gotoScene’

My code:

\_W = display.viewableContentWidth; \_H = display.viewableContentHeight; \_M = display.contentWidth; \_E = display.contentHeight; --media.playSound("audio/music.wav", true); -- musica de fundo local storyboard = require "storyboard" local scene = storyboard.newScene() local ESQUERDA = 0 local DIREITA = 1 local CIMA = -display.viewableContentHeight; local BAIXO = display.viewableContentHeight; local velocidade = 0.2 -- velocidade da animacao de fundo local widthCentro = \_W \* 0.5; -- centro largura local heightCentro = \_H \* 0.5; -- centro altura local background; local tree; local scoreText; local sheet1; local parado; local obstaculos; local grass; local grass2; function scene:createScene( e ) local view = self.view; background = display.newImage("imagens/sky.png", widthCentro, heightCentro); tree = {} tree[1] = display.newImage( "imagens/Palm-arecaceae.png" ) tree[1].xScale = 0.7; tree[1].yScale = 0.7 tree[1].anchorY = 1 tree[1].x = 50; tree[1].y = display.contentHeight tree[1].dx = 0.1 tree[2] = display.newImage( "imagens/Greenhouse-Palm-jubaea01.png" ) tree[2].xScale = 0.6 tree[2].yScale = 0.6 tree[2].anchorY = 1 + 20 tree[2].dx = 0.2 scoreText = display.newText("Score:", 0, 0, native.systemFont, 15); scoreText:setFillColor( 255, 255, 0 ) scoreText.anchorX = 0.5 scoreText.anchorY = 0.5 sheet1 = graphics.newImageSheet( "imagens/sonic.png", { width=102, height=115, numFrames=20 } ) parado = display.newSprite( sheet1, { name="sonicParado", start=1, count=1, time=900 } ) parado.x = 60 parado.y = BAIXO - 8 parado.xScale = .6 parado.yScale = .6 obstaculos = {} obstaculos[1] = display.newImage( "imagens/box01.png" ) obstaculos[1].x = 150; obstaculos[1].y = 270 obstaculos[1].dx = 0.1 obstaculos[2] = display.newImage( "imagens/box02.png" ) obstaculos[2].x = 160; obstaculos[2].y = 223; obstaculos[2].dx = 0.1 -- Grass -- This is doubled so we can slide it -- When one of the grass images slides offscreen, we move it all the way to the right of the next one. grass = display.newImage( "imagens/grass.png" ) grass.anchorX = ESQUERDA grass.x = 0 grass.y = 280 grass2 = display.newImage( "imagens/grass.png" ) grass2.anchorX = ESQUERDA grass2.x = 480 grass2.y = 280 view:insert(background); view:insert(tree[1]); view:insert(tree[2]); view:insert(scoreText); view:insert(parado); view:insert(obstaculos[1]); view:insert(obstaculos[2]); view:insert(grass); view:insert(grass2); end function scene:enterScene( e ) --tempo sistema local tPrevious = system.getTimer() -- função para mover o cenario local function move(event) local tDelta = event.time - tPrevious tPrevious = event.time local xOffset = ( velocidade \* tDelta ) -- velocidade da grama grass.x = grass.x - xOffset grass2.x = grass2.x - xOffset if (grass.x + grass.contentWidth) \< 0 then grass:translate( 480 \* 2, 0) end if (grass2.x + grass2.contentWidth) \< 0 then grass2:translate( 480 \* 2, 0) end local i for i = 1, #tree, 1 do tree[i].x = tree[i].x - tree[i].dx \* tDelta \* velocidade -- 0.2 velocidade das arvores if (tree[i].x + tree[i].contentWidth) \< 0 then tree[i]:translate( 480 + tree[i].contentWidth \* 2, 0 ) end end for i = 1, #obstaculos, 1 do obstaculos[i].x = obstaculos[i].x - obstaculos[i].dx \* tDelta \* velocidade -- 0.2 velocidade das arvores if (obstaculos[i].x + obstaculos[i].contentWidth) \< 0 then obstaculos[i]:translate( 480 + obstaculos[i].contentWidth \* 2, 0 ) end end end local function hasCollided( obj1, obj2) if ( obj1 == nil ) then --make sure the first object exists return false end if ( obj2 == nil ) then --make sure the other object exists return false end local left = obj1.contentBounds.xMin \<= obj2.contentBounds.xMin and obj1.contentBounds.xMax \>= obj2.contentBounds.xMin local right = obj1.contentBounds.xMin \>= obj2.contentBounds.xMin and obj1.contentBounds.xMin \<= obj2.contentBounds.xMax local up = obj1.contentBounds.yMin \<= obj2.contentBounds.yMin and obj1.contentBounds.yMax \>= obj2.contentBounds.yMin local down = obj1.contentBounds.yMin \>= obj2.contentBounds.yMin and obj1.contentBounds.yMin \<= obj2.contentBounds.yMax return (left or right) and (up or down) end local function gameLoop( event ) for i = 1,table.maxn( obstaculos ) do if ( obstaculos[i] and hasCollided( parado, obstaculos[i]) ) then gameOver(); end end return true end Runtime:addEventListener( "enterFrame", move ) Runtime:addEventListener( "enterFrame", gameLoop ) end function scene:exitScene( e ) Runtime:removeEventListener( "enterFrame", move ); Runtime:removeEventListener( "enterFrame", gameLoop ); storyboard.removeScene( "scene1" ) -- dando problema end function gameOver( ) -- velocidade = 0; -- local logo = display.newText( "GAME OVER", 0, 0, "AmericanTypewriter-Bold", 40) -- logo.x = display.contentWidth / 2 -- logo.y = display.contentHeight / 2 -- logo:setFillColor( 255, 255, 0/255, 170/255 ) storyboard.gotoScene( "scene2","fromTop", 1000); end scene:addEventListener( "createScene", scene ); scene:addEventListener( "enterScene", scene ); scene:addEventListener( "exitScene", scene ); return scene;

In the forum thread here, the guy had the same problem as me, he removed the line storyboard.removeScene (“scene1”) and worked with me also worked, however doing so does not work the effects of transitions from one scene to another . So right would fix the problem that is giving. 

Would anyone tell what would it be? 

Thank you very much.

Hello I’m also experiencing the same error

bad argument #-2 to ‘insert’ (Proxy expected, got nil)

my code is

enemyTab[1] = function(group)

    group:insert(enemy)

end

which is inside a function called createBlock or some function

enemyTabrandom(1, #enemyTab)

The enemy represent as display.newSprite() using Zwoptex sprite sheets at graphics 2.0 version
The code is

SSEnemyFlySheetData = require(“sheets.enemyFlySheet”).getSpriteSheetData()
SSEnemyFlyOptions = {
    spriteSheetFrames = SSEnemyFlySheetData.frames
}
SSEnemyFly = graphics.newImageSheet(“sheets/enemyFlySheet.png”, SSEnemyFlyOptions)

enemySequence_fly = {
    {name = “normal”, start = 1, count = 2, time = 300, loopCount = 0},
    {name = “die”, start = 3, count = 1, time = 500, loopCount = 1},

}

flyEnemySet = display.newSprite(SSEnemyFly, enemySequence_fly)

Please help!

Hello I’m also experiencing the same error

bad argument #-2 to ‘insert’ (Proxy expected, got nil)

my code is

enemyTab[1] = function(group)

    group:insert(enemy)

end

which is inside a function called createBlock or some function

enemyTabrandom(1, #enemyTab)

The enemy represent as display.newSprite() using Zwoptex sprite sheets at graphics 2.0 version
The code is

SSEnemyFlySheetData = require(“sheets.enemyFlySheet”).getSpriteSheetData()
SSEnemyFlyOptions = {
    spriteSheetFrames = SSEnemyFlySheetData.frames
}
SSEnemyFly = graphics.newImageSheet(“sheets/enemyFlySheet.png”, SSEnemyFlyOptions)

enemySequence_fly = {
    {name = “normal”, start = 1, count = 2, time = 300, loopCount = 0},
    {name = “die”, start = 3, count = 1, time = 500, loopCount = 1},

}

flyEnemySet = display.newSprite(SSEnemyFly, enemySequence_fly)

Please help!