# Makecode is hallucinating errors when setting variables to a value of a sprite array

**URL:** <https://forum.makecode.com/t/makecode-is-hallucinating-errors-when-setting-variables-to-a-value-of-a-sprite-array/39278>\
**Category:** Help\
**Created:** [September 15, 2025, 4:40pm UTC](https://forum.makecode.com/t/makecode-is-hallucinating-errors-when-setting-variables-to-a-value-of-a-sprite-array/39278 "2025-09-15T16:40:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![SouperMediocre1](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/soupermediocre1/32/22579_2.png) [@SouperMediocre1](https://forum.makecode.com/u/SouperMediocre1)\
**Post date:** [September 15, 2025, 4:40pm UTC](https://forum.makecode.com/t/makecode-is-hallucinating-errors-when-setting-variables-to-a-value-of-a-sprite-array/39278/1 "2025-09-15T16:40:38Z")

</div>

as the title says. i made a for element value of (array of sprites of type) loop, then, in that loop i have a block setting a newly made variable with no other uses to “value”. Makecode gave me an error saying “type sprite is not assignable to type number”. the error does not happen if i were to set the variable to something like “get first value from (array of sprites of type)”, even though that should be the same value.

fairly sure this is new. i swear ive done this in other projects and not gotten a bug.

---

<div class="post-metadata">

**Author:** ![MeatballDev](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/meatballdev/32/28502_2.png) [@MeatballDev](https://forum.makecode.com/u/MeatballDev)\
**Post date:** [September 15, 2025, 5:21pm UTC](https://forum.makecode.com/t/makecode-is-hallucinating-errors-when-setting-variables-to-a-value-of-a-sprite-array/39278/2 "2025-09-15T17:21:33Z")

</div>

I hast been summoned, send me thy holy link

---

<div class="post-metadata">

**Author:** ![WoofWoof](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/woofwoof/32/32523_2.png) [@WoofWoof](https://forum.makecode.com/u/WoofWoof)\
**Post date:** [September 15, 2025, 6:12pm UTC](https://forum.makecode.com/t/makecode-is-hallucinating-errors-when-setting-variables-to-a-value-of-a-sprite-array/39278/3 "2025-09-15T18:12:35Z")

</div>

This is an issue with how blocks are translated to javaScript internally. I don’t know how simple of a fix this could be on the Makecode Dev side, (@richard is this just something that isn’t being checked when making variable definitions?) but I can say that doing something else to tell Makecode that the variable is indeed a sprite will usually solve this issue, for example doing something like this:

 ![Screenshot 2025-09-15 at 1.33.09 PM](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/a/3/a3a1acf3d0404a8643dea623bfc842ed9da2ac0a.png)  
This just jabs Makecode a bit to remind it that “var” is supposed to be a sprite. Essentially the issue is that Makecode isn’t looking at “value” to define what “var” is, so it doesn’t know “var” is a sprite.

---

<div class="post-metadata">

**Author:** ![SouperMediocre1](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/soupermediocre1/32/22579_2.png) [@SouperMediocre1](https://forum.makecode.com/u/SouperMediocre1)\
**Post date:** [September 15, 2025, 6:16pm UTC](https://forum.makecode.com/t/makecode-is-hallucinating-errors-when-setting-variables-to-a-value-of-a-sprite-array/39278/4 "2025-09-15T18:16:26Z")

</div>

I made a small test program to demonstrate the issue.  
although it seems @WoofWoof beat me to it.

> **[hallucinating error test](https://arcade.makecode.com/S25419-32288-32982-66940)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

**Author:** ![redSprite](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/redsprite/32/34262_2.png) [@redSprite](https://forum.makecode.com/u/redSprite)\
**Post date:** [September 15, 2025, 7:34pm UTC](https://forum.makecode.com/t/makecode-is-hallucinating-errors-when-setting-variables-to-a-value-of-a-sprite-array/39278/5 "2025-09-15T19:34:53Z")

</div>

What I do is make a separate variable that is defined as a sprite, set “var” to that variable so it knows it is a sprite, go on with regular code, then destroy the sprite that helped define “var”.
