# Debug Student game

**URL:** <https://forum.code.org/t/debug-student-game/40668>\
**Category:** Uncategorized\
**Created:** [April 11, 2025, 8:08pm UTC](https://forum.code.org/t/debug-student-game/40668 "2025-04-11T20:08:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lorikaye](https://avatars.discourse-cdn.com/v4/letter/l/dc4da7/32.png) [@lorikaye](https://forum.code.org/u/lorikaye)\
**Post date:** [April 11, 2025, 8:08pm UTC](https://forum.code.org/t/debug-student-game/40668/1 "2025-04-11T20:08:14Z")

</div>

My student needs help debugging this:

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

What is supposed to happen:  
Round the number to the nearest integer

What is happening:

On line 122 and on line 128 the math.round block is not rounding my number. In my code it takes the position of the world mouse and puts it in a variable, then it divides 100 times by 2 and then rounds. After that it undoes the multiplication and divisions which should round it to the nearest 50 pixels. The multiplication and division works but the Math.round does not.

What I have tried:

I have tried using different variable names, since I like coding by hand I switched to blocks and tried adding another rounding block, and I tried adding code to run one one thing at a time that I could control with the keyboard. I have no idea what could be causing this problem because I know the if statement it is in is working. Also the round block worked earlier in my code.

---

<div class="post-metadata">

**Author:** ![varrience](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/varrience/32/8042_2.png) [@varrience](https://forum.code.org/u/varrience)\
**Post date:** [April 12, 2025, 12:38am UTC](https://forum.code.org/t/debug-student-game/40668/2 "2025-04-12T00:38:35Z")

</div>

`Math.round` returns the rounded number given in the argument, it however does not assign it to the variable! here’s what you should be doing instead

```auto
mouseposy = Math.round(mouseposy);

```

this sets the variable your trying to round to the output being returned by `Math.round`
