I have a simple storyboard setup.
Main to menu to either levelSelection or options. levelSelection to level1,2,3, etc.
I get no errors if I do menu - levelSelection - level1.
When I go menu - levelSelection - level1 - levelSelection - level1 I get the "Attempt to call method ‘(somemethod)’ (a nil value)… "
I get the same error if I go menu - options - menu - levelSelection - level1
The method in question is “getLinearVelocity()” in cube:touch
function helperFunctions.createCube( size, x, y ) -- Create cube local cube = display.newRect( x, y, size, size ) cube:setFillColor( 178 ) cube.isFixedRotation = true local density = 2025 / (size\*size) physics.addBody( cube, { density=density, friction=0, bounce=0 } ) -- Touch method function cube:touch( event ) local vx, vy = self:getLinearVelocity() if( vx == 0 and vy == 0) then if event.phase == "began" then -- blah blah end return true end end cube:addEventListener( "touch", cube ) return cube end
in my level1.lua at the top I do: local helperFunctions = require( “helperFunctions” )
and in scene:createScene: cube = helperFunctions.createCube( 45, 15, 15 )
I found metatables to be connected with this sort of error when I researched it.
Is that something I have to implement?

