# Need help with an error

**URL:** <https://forum.code.org/t/need-help-with-an-error/24238>\
**Category:** CS Discoveries\
**Created:** [January 22, 2019, 5:53pm UTC](https://forum.code.org/t/need-help-with-an-error/24238 "2019-01-22T17:53:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![smcelwrath](https://avatars.discourse-cdn.com/v4/letter/s/5fc32e/32.png) [@smcelwrath](https://forum.code.org/u/smcelwrath)\
**Post date:** [January 22, 2019, 5:53pm UTC](https://forum.code.org/t/need-help-with-an-error/24238/1 "2019-01-22T17:53:30Z")

</div>

I have a few students that have been working on Unit 3 Lesson 22 to complete their own games. One day their code works fine, they shut the program and make no further changes. The next when they log back in, they get a Function error on line 42 (It’s always line 42 no matter what). I’m at a loss and the students are stuck.

Any ideas? I’ve shared a link to one of the student’s games here: [https://studio.code.org/projects/gamelab/w0y1eKuyzCZ76IUth2hUJ4FLA1IpZAEb3UyymFEx3BE](https://studio.code.org/projects/gamelab/w0y1eKuyzCZ76IUth2hUJ4FLA1IpZAEb3UyymFEx3BE)

Thanks!

---

<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:** [January 22, 2019, 8:13pm UTC](https://forum.code.org/t/need-help-with-an-error/24238/2 "2019-01-22T20:13:19Z")

</div>

@smcelwrath

Hi Stephanie,

Really interesting bug! I’ll start off with the background of what happened and the debugging process in case you want to tell your students, but if you want you can skim to the end.

Usually an error message like this means that you are treating something as a function (calling it), even though it is not one. This can either be because you forgot to define the function, misspelled it, or (most commonly) have redefined your function as something else in a different place in the program.

In this case, it’s a little more tricky. The error is showing up right after the conditional that asks about `Chick1.isTouching(Fence)`. Even though that’s not a function on its own, the `isTouching` method acts like a function when it’s attached to a sprite. When it’s NOT attached to a sprite, though, it doesn’t mean anything.

If you scroll down to line 115, you’ll see that the value of Chick1 is set to `true` or `false`. That means that it’s not a sprite anymore, so next time the program checks for `Chick1.isTouching(Fence)`, the `isTouching` method doesn’t mean anything anymore.

I’m not sure exactly what the students were intending to do in setting the values of their sprites to `true` or `false` (maybe `destroy` them or set their `visible` property to `false`?), but fixing that should fix the program.

Elizabeth

---

<div class="post-metadata">

**Author:** ![smcelwrath](https://avatars.discourse-cdn.com/v4/letter/s/5fc32e/32.png) [@smcelwrath](https://forum.code.org/u/smcelwrath)\
**Post date:** [January 24, 2019, 5:52pm UTC](https://forum.code.org/t/need-help-with-an-error/24238/3 "2019-01-24T17:52:37Z")

</div>

Thank you so much! She actually had made a variable and named it the same as her sprite. So when she referred to the variable being true or false it confused the code. She changed the code for the variables and now it’s working perfectly! Thank you so much for your help and quick response!
