# Help! Getting an error message I'm not familiar with

**URL:** <https://forum.code.org/t/help-getting-an-error-message-im-not-familiar-with/22451>\
**Category:** Unit and Lesson Discussion\
**Tags:** csd-unit-3, csd-unit-3-lesson-14\
**Created:** [November 22, 2018, 1:13am UTC](https://forum.code.org/t/help-getting-an-error-message-im-not-familiar-with/22451 "2018-11-22T01:13:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sarah.dudley](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@sarah.dudley](https://forum.code.org/u/sarah.dudley)\
**Post date:** [November 22, 2018, 1:13am UTC](https://forum.code.org/t/help-getting-an-error-message-im-not-familiar-with/22451/1 "2018-11-22T01:13:24Z")

</div>

The student is trying to create his card. I am including a link to the card so you can see the code. He keeps getting a message that says, “Cannot read property x undefined.” or sometimes it says “Cannot read property y undefined.” I think it is because he has all the variables in an if statement inside the draw loop. The reason he is doing this is because he does not want anything to show up until the user pushes the space key. Is there another way for him to make this happen?

> **[Check out what I made](https://studio.code.org/projects/gamelab/PZwMR_PPeXoGzv754Een0fRGMdWqKL27sLPSQJrQg4k)**
>
> I wrote the code myself with Code.org

---

<div class="post-metadata">

**Author:** ![bradleywellsashley](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/bradleywellsashley/32/522_2.png) [@bradleywellsashley](https://forum.code.org/u/bradleywellsashley)\
**Post date:** [November 26, 2018, 3:06am UTC](https://forum.code.org/t/help-getting-an-error-message-im-not-familiar-with/22451/4 "2018-11-26T03:06:18Z")

</div>

Sarah,

Currently the purple and red aliens are only created if the `if` condition is met. You want to take all the sprites in the game and create them/scale them outside of the `if statement`. That cleared up the warnings, but I don’t know what else the students wanted the game to do…

Hope that helps!  
Brad

---

<div class="post-metadata">

**Author:** ![sarah.dudley](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@sarah.dudley](https://forum.code.org/u/sarah.dudley)\
**Post date:** [November 26, 2018, 3:21am UTC](https://forum.code.org/t/help-getting-an-error-message-im-not-familiar-with/22451/6 "2018-11-26T03:21:46Z")

</div>

Thank you, that’s what I was thinking as well. The student is wanting the first scene to be plain white with the directions/words on it, then when the left mouse button is pushed he wants it to change scenes to the grass with the aliens that move. When I had him move the sprites outside of the if statement, it gives grey boxes where the sprites would be.

---

<div class="post-metadata">

**Author:** ![elizabeth\_admin](https://avatars.discourse-cdn.com/v4/letter/e/bb73d2/32.png) [@elizabeth\_admin](https://forum.code.org/u/elizabeth_admin)\
**Post date:** [November 26, 2018, 7:29pm UTC](https://forum.code.org/t/help-getting-an-error-message-im-not-familiar-with/22451/7 "2018-11-26T19:29:29Z")

</div>

HI Sarah,

This appears to be working properly now. Was the student able to fix it?

Elizabeth
