2D Side Scrolling Spawn enemy help

Trying to spawn enemys on the both side of the screen, on the outside so they walk in to the player, but nothing I do seems to work.

srry here is the code I am complete new to coding I am a artist my friend codes but he is on vacation just want to get it done.

local function spawnenemy()
  
  local enemy=display.newImage(“images/sprite/solider1.png”)
  enemy.x=485
  enemy.y=290
  physics.addBody(enemy, “dynamic”, {density=.2,friction=.5,bounce=0.1})
  
 
 function spawnright_left(event)
  if enemy.x<480 then
     enemy.x=485
  elseif
     enemy.x>0 then
     enemy.x=-8
  end
  end
  enemy:addEventListener(“enemy”,spawnright_left)
 end
 timer.performWithDelay(2000,spawnenemy,1000);

srry here is the code I am complete new to coding I am a artist my friend codes but he is on vacation just want to get it done.

local function spawnenemy()
  
  local enemy=display.newImage(“images/sprite/solider1.png”)
  enemy.x=485
  enemy.y=290
  physics.addBody(enemy, “dynamic”, {density=.2,friction=.5,bounce=0.1})
  
 
 function spawnright_left(event)
  if enemy.x<480 then
     enemy.x=485
  elseif
     enemy.x>0 then
     enemy.x=-8
  end
  end
  enemy:addEventListener(“enemy”,spawnright_left)
 end
 timer.performWithDelay(2000,spawnenemy,1000);