# What is the best way to fix this

**URL:** <https://forum.makecode.com/t/what-is-the-best-way-to-fix-this/37264>\
**Category:** Help\
**Tags:** game\
**Created:** [June 11, 2025, 5:37pm UTC](https://forum.makecode.com/t/what-is-the-best-way-to-fix-this/37264 "2025-06-11T17:37:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![randomDUck](https://avatars.discourse-cdn.com/v4/letter/r/977dab/32.png) [@randomDUck](https://forum.makecode.com/u/randomDUck)\
**Post date:** [June 11, 2025, 5:37pm UTC](https://forum.makecode.com/t/what-is-the-best-way-to-fix-this/37264/1 "2025-06-11T17:37:54Z")

</div>

it is saying failed cast on null and i want to fix it. and get the arrays working.

> **[duck in a dungeon](https://arcade.makecode.com/99277-83717-69174-96413)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

**Author:** ![Bilangus](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/bilangus/32/33219_2.png) [@Bilangus](https://forum.makecode.com/u/Bilangus)\
**Post date:** [June 11, 2025, 11:40pm UTC](https://forum.makecode.com/t/what-is-the-best-way-to-fix-this/37264/2 "2025-06-11T23:40:09Z")

</div>

Usually failed cast on null errors happen when you try to do something with a variable before its been set. I dont know much of anything about javascript so i cant help much beyond that.

---

<div class="post-metadata">

**Author:** ![randomDUck](https://avatars.discourse-cdn.com/v4/letter/r/977dab/32.png) [@randomDUck](https://forum.makecode.com/u/randomDUck)\
**Post date:** [June 12, 2025, 3:15am UTC](https://forum.makecode.com/t/what-is-the-best-way-to-fix-this/37264/3 "2025-06-12T03:15:48Z")

</div>

thank you, i solved it using an old post.

It was trying to run the set position before the sprite was created even though it was below it;  
I made a function which seemed to solve it.

here was the solution:

```
function location(sprite: Sprite, column: number, row: number) {
    sprite.x = column * 16
    sprite.y = row * 16
}

```
