bad argument #-1 'addBody' (Proxy expected, got nil)

local physics = require "physics" physics.start(); physics.pause() local function spawnCharacter() physics.addBody( character1, "dynamic", {filter=guyCollisionFilter} ) end local function spawnCharacter1() physics.addBody( character2, "dynamic", {filter=guyCollisionFilter} ) end local function spawnCharacter2() physics.addBody( character3, "dynamic", {filter=guyCollisionFilter} ) end local function spawnCharacter3() physics.addBody( character4, "dynamic", {filter=guyCollisionFilter} ) end local function spawnBomb() physics.addBody( bomb, "dynamic", {filter=bombCollisionFilter} ) end local function spawnBomb1() physics.addBody( bomb1, "dynamic", {filter=bombCollisionFilter} ) end local function spawnBomb2() physics.addBody( bomb2, "dynamic", {filter=bombCollisionFilter} ) end timer.performWithDelay( 9000, spawnCharacter, 0 ) timer.performWithDelay( 12000, spawnCharacter1, 0 ) timer.performWithDelay( 18000, spawnCharacter2, 0 ) timer.performWithDelay( 25000, spawnCharacter3, 0 ) timer.performWithDelay( 23000, spawnCharacter4, 0 ) timer.performWithDelay( 8000, spawnBomb, 0 ) timer.performWithDelay( 15000, spawnBomb1, 0 ) timer.performWithDelay( 24000, spawnBomb2, 0 ) 

Ran into another error yesterday and its been driving me crazy as I haven’t been able to find a solution for it, anyway the error is in the title and happens at the end of the game when the time has run out, it will usually happen 5 seconds after that, and will still happen if the user clicks the menu button at the end of the level. Does anyone have a solution?

Your timers are running infinitely. You need to cancel them when your game ends/character dies/player wins. You could try something like this:

timerStash = {} local function cancelAllTimers() local k, v for k,v in pairs(timerStash) do timer.cancel( v ) v = nil; k = nil end timerStash = nil timerStash = {} end --EXAMPLE --timerStash.timer1 = timer.performWithDelay( 24000, spawnBomb2, 0 ) --When Game Ends Do this cancelAllTimers()

Your timers are running infinitely. You need to cancel them when your game ends/character dies/player wins. You could try something like this:

timerStash = {} local function cancelAllTimers() local k, v for k,v in pairs(timerStash) do timer.cancel( v ) v = nil; k = nil end timerStash = nil timerStash = {} end --EXAMPLE --timerStash.timer1 = timer.performWithDelay( 24000, spawnBomb2, 0 ) --When Game Ends Do this cancelAllTimers()