# Stop a sprite at a specific location

**URL:** <https://forum.code.org/t/stop-a-sprite-at-a-specific-location/12138>\
**Category:** Unit and Lesson Discussion\
**Tags:** csd-unit-3, csd-unit-3-lesson-9\
**Created:** [November 21, 2017, 6:59pm UTC](https://forum.code.org/t/stop-a-sprite-at-a-specific-location/12138 "2017-11-21T18:59:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![m\_viscarri](https://avatars.discourse-cdn.com/v4/letter/m/49beb7/32.png) [@m\_viscarri](https://forum.code.org/u/m_viscarri)\
**Post date:** [November 21, 2017, 6:59pm UTC](https://forum.code.org/t/stop-a-sprite-at-a-specific-location/12138/1 "2017-11-21T18:59:43Z")

</div>

I have a student that would like to have his sprite stop when it reaches a specific location. How do we do this?

---

<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 23, 2017, 12:11am UTC](https://forum.code.org/t/stop-a-sprite-at-a-specific-location/12138/2 "2017-11-23T00:11:28Z")

</div>

@m_viscarri

Hi Misty,

It’s great that your students are asking this, because it’s going to be covered in the next couple of lessons on conditionals.

You’ll need to use a conditional to only change the sprite movement when it is not yet where you want it to stop. The instructions to the computer would look something like:

`if the sprite is to the left of this position`  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`move it to the right`

In Javascript, that would be:  
`if (sprite.x < stopCoordinate) {`  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`sprite.x = sprite.x + 5;`  
`}`

Here’s an example of how the code might look: [Stop a Sprite Example](https://studio.code.org/projects/gamelab/GdBbKm45y3IbebTKWGIvpWORyEjhZR-jVaPbcSxrI4Q)

I also think this is a great example of when you can tell a student that it’s wonderful that she’s thinking along those lines, and that the class will be covering it so stay tuned. If you don’t have one, it might be fun to have a “Things we want to learn how to do” poster and cross things off as you get to them throughout the lessons. It could also be a differentiation tactic for the kids who are ready to explore on their own and answer some of the questions for the class.

(Hope the answer didn’t get too off track, but I really liked my poster for all those types of questions. 😃 )

Elizabeth
