Need help trying to go to next scene

Hello! I am trying to out in a button to go to the next scene but i keep getting an error i dont know what im doing wrong? If anyone could help me i would really appreciate it :slight_smile:

local storyboard = require( “storyboard” )
    local scene = storyboard.newScene()

    physics.setScale( 25 )
     
    – local forward references should go here –
     
    local function btnTap(event)
    storyboard.gotoScene ( event.target.destination, {effect = “fade”} )
    return true
    end
     
    – Called when the scene’s view does not exist:
    function scene:createScene( event )
    local group = self.view
     
    – CREATE display objects and add them to ‘group’ here.
    – Example use-case: Restore ‘group’ from previously saved state.
   local background1 = display.newImageRect(“background3.png”, 320, 480)
    background1.x = dW/2
    background1.y = dH/2
    group:insert(background1)

   local logo = display.newImage(“hballoon.png”)
    logo.x = centerX
    logo.y = centerY + -125
    logo.alpha = 1
    logo.xScale = .65
    logo.yScale = 1
    group:insert(logo)

    local balloonBlue = display.newImageRect( “balloonblue.png”, 50, 50 )
    balloonBlue.x = 40
    balloonBlue.y = 10
    balloonBlue.myName = “bBlue”
    physics.addBody(balloonBlue,“dynamic”, {density=.25, friction=10, bounce = .4, radius=27})
    balloonBlue.angularDamping = 10
    balloonBlue.linearDamping = 2
    group:insert(balloonBlue)

    local balloonPurple = display.newImageRect( “balloonpurple.png”, 50, 50 )
    balloonPurple.x = 100
    balloonPurple.y = -25
    balloonPurple.myName = “bPurple”
    physics.addBody(balloonPurple, “dynamic”, {density=.25, friction=10, bounce = .4, radius=27})
    balloonPurple.angularDamping = 10
    balloonPurple.linearDamping = 2
    group:insert(balloonPurple)

    local balloonYellow = display.newImageRect( “balloonyellow.png”, 50, 50 )
    balloonYellow.x = 160
    balloonYellow.y = -10
    balloonYellow.myName = “bYellow”
    physics.addBody(balloonYellow, “dynamic”, {density=.25, friction=10, bounce = .4, radius=27})
    balloonYellow.angularDamping = 10
    balloonYellow.linearDamping = 2
    group:insert(balloonYellow)

    local balloonRed = display.newImageRect( “balloonred.png”, 50, 50 )
    balloonRed.x = 220
    balloonRed.y = -40
    balloonRed.myName = “bRed”
    physics.addBody(balloonRed, “dynamic”, {density=.25, friction=10, bounce = .4, radius=27})
    balloonRed.angularDamping = 10
    balloonRed.linearDamping = 2
    group:insert(balloonRed)  

    local balloonGreen = display.newImageRect( “balloongreen.png”, 50, 50 )
    balloonGreen.x = 280
    balloonGreen.y = -5
    balloonGreen.myName = “bGreen”
    physics.addBody(balloonGreen, “dynamic”, {density=.25, friction=10, bounce = .4, radius=27})
    balloonGreen.angularDamping = 10
    balloonGreen.linearDamping = 2
    group:insert(balloonGreen)

    local roof = display.newRect( 0, 0, 320, 1)
    roof.anchorX = 0.5
    roof.anchorY = 0.5
    roof.x = 160
    roof.y = -85
    physics.addBody(roof, “static”, { density = 10, friction = 1, bounce = 1} )
    group:insert(roof)

    local leftwall= display.newRect(0, 0, 1, 480)
    leftwall.anchorX = 0.5
    leftwall.anchorY = 0.5
    leftwall.x = -1;
    leftwall.y = 129
    physics.addBody(leftwall, “static”, {density = 10, friction = 0.3, bounce = .5})
    group:insert(leftwall)

    local rightwall = display.newRect(0, 0, 1, 480)
    rightwall.anchorX = 0.5
    rightwall.anchorY = 0.5
    rightwall.x = 321;
    rightwall.y = 129
    physics.addBody(rightwall, “static”, {density = 10, friction = 0.3, bounce = .5})
    group:insert(rightwall)

    local groundT = display.newImageRect(“wireTop.png”, 320, 15 )
    groundT.x = 160;
    groundT.y = 556
    groundT.rotation = 0
    group:insert(groundT)

    local ground = display.newImageRect(“wire.png”, 320, 37 )
    ground.x = 160;
    ground.y = 556
    ground.rotation = 0
    ground.myName = “wire”
    physics.addBody(ground, “static”, {density = 10, friction = 0.3, bounce = .5})
    group:insert(ground)

    function onLocalCollision( self, event )
        if ( event.phase == “began” and self.myName == “circle” ) then
            local forcex = event.other.x-self.x
            local forcey = event.other.y-self.y
            if(forcex < 0) then
                forcex = 0-(80 + forcex)-12
            else
                forcex = 80 - forcex+12
            end
            event.other:applyForce( forcex, forcey, self.x, self.y )
        end
    end
    
    function setBomb ( event )
        if(event.phase == “began”) then
            circle = display.newCircle( event.x, event.y, 50 )
            circle:setFillColor(0,0,0, 0)
            group:insert(circle)
            physics.addBody( circle, “static”, {isSensor = true} )
            circle.myName = “circle”
            circle.collision = onLocalCollision
            circle:addEventListener( “collision”,  circle )
        end
        if(event.phase == “ended”) then
            circle:removeSelf()
        end
        

    end
    background1:addEventListener(“touch”,setBomb)

function ground:collision( event )
        if event.other.myName == “bGreen” then
            audio.play(popSound)            
            balloonGreen:removeSelf( )      

            --Hidden Object - Quick Fix for Removing Blue Balloon
            balloonGreen = display.newImageRect( “balloongreen.png”, 50, 50 )
            balloonGreen.x = -50
            balloonGreen.y = 25
        elseif event.other.myName == “bRed” then
            audio.play(popSound)            
            balloonRed:removeSelf( )        

            --Hidden Object - Quick Fix for Removing Blue Balloon
            balloonRed = display.newImageRect( “balloonred.png”, 50, 50 )
            balloonRed.x = -50
            balloonRed.y = 25
        elseif event.other.myName == “bYellow” then
            audio.play(popSound)            
            balloonYellow:removeSelf( )     

            --Hidden Object - Quick Fix for Removing Blue Balloon
            balloonYellow = display.newImageRect( “balloonyellow.png”, 50, 50 )
            balloonYellow.x = -50
            balloonYellow.y = 25
        elseif event.other.myName == “bPurple” then
            audio.play(popSound)            
            balloonPurple:removeSelf( )     

            --Hidden Object - Quick Fix for Removing Blue Balloon
            balloonPurple = display.newImageRect( “balloonpurple.png”, 50, 50 )
            balloonPurple.x = -50
            balloonPurple.y = 25
        elseif event.other.myName == “bBlue” then
            audio.play(popSound)            
            balloonBlue:removeSelf( )       

            --Hidden Object - Quick Fix for Removing Blue Balloon
            balloonBlue = display.newImageRect( “balloonblue.png”, 50, 50 )
            balloonBlue.x = -50
            balloonBlue.y = 25          
        end
end
    
    ground:addEventListener( “collision”, ground )

    btnTap = ui.newButton{  – this is the start of a button from the class “startBtn” defines the object.
            defaultSrc = “arrowD.png”,
            defaultX = 100,
            defaultY = 70,
            overSrc = “arrowO.png”,
            overX = 100,
            overY = 70,
            onEvent = onstartBtnTouch,  --this is the eventlistener we have NOT created yet…
            id = “return button”, --this is a debug tool as far as i know
            text = “Start”,
            font = “Noteworthy”, --you can play with the font any time… that is simple.
            textColor = { 255, 255, 255, 255 },
            size = 18,
            emboss = false
        }
        
        --now we need to locate the button
        group.btnTap.anchorX = 0.5
        group.btnTap.anchorY = 0        
        group.btnTap.x = 160 obj.btnTap.y = 425
        group.btnTap.isVisible = true
        group:insert(btnTap)

    end
     
    – Called immediately after scene has moved onscreen:
function scene:enterScene( event )
    local group = self.view
     
    – INSERT code here (e.g. start timers, load audio, start listeners, etc.)
        local popSound = audio.loadSound( “pop.wav” )

        local function onClickNextButtont()  – called from button you create after level completion
        local onstartBtnTouch = function (event)
            if event.phase == “release” and btnTap.isActive then
                btnTaptimer = timer.performWithDelay( 50, func) --s[1] ) --we only have one function at this point in time back in main.lua
                group:remove() --removes objects currently on screen.             
            end
        end

      storyboard.gotoScene( “level2”,{effect = crossFade} )

end
     
    – Called when scene is about to move offscreen:
    function scene:exitScene( event )
    local group = self.view
        
        if self.btnTaptimer then timer.cancel ( self.btnTaptimer ); self.btnTaptimer=nil; end     
        if self.fadeTmr then transition.cancel ( self.fadeTmr ); self.fadeTmr=nil; end
            circle:removeEventListener( “collision”, circle )
            if circle then circle:removeSelf( ); circle = nil; end
            background1:removeEventListener( “touch”, setBomb )
            ground:removeEventListener( “collision”, ground )

    – INSERT code here (e.g. stop timers, remove listeners, unload sounds, etc.)
    – Remove listeners attached to the Runtime, timers, transitions, audio tracks
     
    end
     
    – Called prior to the removal of scene’s “view” (display group)
    function scene:destroyScene( event )
    local group = self.view
     
     function obj:remove()
            self.background1:removeSelf( )              
            self.startBtn:removeSelf( )
            self.balloonBlue:removeSelf( )
            self.balloonGreen:removeSelf( )
            self.balloonRed:removeSelf( )
            self.balloonYellow:removeSelf( )
            self.balloonPurple:removeSelf( )            
            self.roof:removeSelf( )
            self.leftwall:removeSelf( )
            self.rightwall:removeSelf( )
            self.groundT:removeSelf( )
            self.ground:removeSelf( )
            self.startBtn:removeSelf( )
            self.logo:removeSelf()
    
        
            self:removeSelf()
        end
    
    return obj
    – INSERT code here (e.g. remove listeners, widgets, save state, etc.)
    – Remove listeners attached to the Runtime, timers, transitions, audio tracks
     
    end
     
    ---------------------------------------------------------------------------------
    – END OF YOUR IMPLEMENTATION
    ---------------------------------------------------------------------------------
     
    – “createScene” event is dispatched if scene’s view does not exist
    scene:addEventListener( “createScene”, scene )
     
    – “enterScene” event is dispatched whenever scene transition has finished
    scene:addEventListener( “enterScene”, scene )
     
    – “exitScene” event is dispatched before next scene’s transition begins
    scene:addEventListener( “exitScene”, scene )
     
    – “destroyScene” event is dispatched before view is unloaded, which can be
    – automatically unloaded in low memory situations, or explicitly via a call to
    – storyboard.purgeScene() or storyboard.removeScene().
    scene:addEventListener( “destroyScene”, scene )
     
    ---------------------------------------------------------------------------------
     
    return scene