physics body being removed and not reloaded after scene change

So I am changing scenes from the main game scene to the menu and then back.

When the user goes from the game scene to the menu and back again I keep getting the error message “Attempt to call method ‘getLinearVelocity’ (a nil value)”

but when the user clicks on the replay button which just goes to a new scene and calls removeScene"level1" and then calls storyboard.gotoScene(“level1”) it works

In the menu scene I call removeScene"level1" as well and it doesn’t work for some reason heres my code for various functions

scene:destroy scene in level1.lua is

 package.loaded[physics] = nil physics = nil Runtime:removeEventListener("enterFrame",bird) replaybtn:removeEventListener("touch",replay) menubtn:removeEventListener("touch",menu) Runtime:removeEventListener("touch",touchScreen) Runtime:removeEventListener("collision",onCollision)

in menu.lua enter scene

 storyboard.removeScene( "level1" )

in replay.lua enter scene

 storyboard.removeScene( "level1" ) storyboard.gotoScene("level1")

nvm I figured out a quick way to fix it… I just send the scene back to replay scene and it works now.

nvm I figured out a quick way to fix it… I just send the scene back to replay scene and it works now.