'Error message "Cannot set properties of undefined (setting 'x')"

I got the error message "Cannot set properties of undefined (setting 'x')"

The message directs at this code:

  function spelareHitRoman(spelare, romans){
       roman.position.x = (560+860);
       roman.position.y = random(30+270, 30+270+170);
       myPlayers[0].position.x = 560; 
       myPlayers[0].position.y = random(30+270, 30+270+170);
    }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source