# TypeError: fly.isTouching is not a function

**URL:** <https://forum.code.org/t/typeerror-fly-istouching-is-not-a-function/31762>\
**Category:** Coding and Debugging Help\
**Tags:** csd-unit-3-lesson-18\
**Created:** [November 21, 2019, 4:29pm UTC](https://forum.code.org/t/typeerror-fly-istouching-is-not-a-function/31762 "2019-11-21T16:29:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lkeil](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/lkeil/32/5239_2.png) [@lkeil](https://forum.code.org/u/lkeil)\
**Post date:** [November 21, 2019, 4:29pm UTC](https://forum.code.org/t/typeerror-fly-istouching-is-not-a-function/31762/1 "2019-11-21T16:29:27Z")

</div>

**Link to the project or level:** [https://studio.code.org/projects/gamelab/7YM3cC6WMPSbF97e1t1Ol7LnzTzVWtaCZ0YExnZ\_qgU](https://studio.code.org/projects/gamelab/7YM3cC6WMPSbF97e1t1Ol7LnzTzVWtaCZ0YExnZ_qgU)  
**What I expect to happen:** coin moves to random position and score increases if fly touches it  
**What actually happens:** ERROR: Line: 40: TypeError: fly.isTouching is not a function  
_What I’ve tried (and three students):_\* renaming all sprites, removing and rebuilding the if statement code, switching browsers, logging out/logging in

---

<div class="post-metadata">

**Author:** ![mwood](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/mwood/32/4941_2.png) [@mwood](https://forum.code.org/u/mwood)\
**Post date:** [November 21, 2019, 5:34pm UTC](https://forum.code.org/t/typeerror-fly-istouching-is-not-a-function/31762/2 "2019-11-21T17:34:01Z")

</div>

fly is a sprite, but on line 32, you try to make it a number (-4). I’m guessing you meant fly.velocityY = -4;

The error comes from fly trying to be both a sprite and an integer.

Best of luck!

Mike

---

<div class="post-metadata">

**Author:** ![lkeil](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/lkeil/32/5239_2.png) [@lkeil](https://forum.code.org/u/lkeil)\
**Post date:** [November 21, 2019, 9:45pm UTC](https://forum.code.org/t/typeerror-fly-istouching-is-not-a-function/31762/3 "2019-11-21T21:45:19Z")

</div>

That did need to get corrected.  
But the error is still on line 40 despite that change.

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

---

<div class="post-metadata">

**Author:** ![mwood](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/mwood/32/4941_2.png) [@mwood](https://forum.code.org/u/mwood)\
**Post date:** [November 21, 2019, 9:53pm UTC](https://forum.code.org/t/typeerror-fly-istouching-is-not-a-function/31762/4 "2019-11-21T21:53:07Z")

</div>

Line 28 is also setting fly equal to a number. Something is missing in the first blank. Is it fly.VelocityY …?

Mike

---

<div class="post-metadata">

**Author:** ![lkeil](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/lkeil/32/5239_2.png) [@lkeil](https://forum.code.org/u/lkeil)\
**Post date:** [December 11, 2019, 6:07pm UTC](https://forum.code.org/t/typeerror-fly-istouching-is-not-a-function/31762/5 "2019-12-11T18:07:40Z")

</div>

Thank you for the help! The students were able to correct the errors and successfully get the program to work.  
I GREATLY appreciate your help!! 😃
