# What is wrong with this code?

**URL:** <https://forum.makecode.com/t/what-is-wrong-with-this-code/10809>\
**Category:** Help\
**Created:** [November 9, 2021, 8:40pm UTC](https://forum.makecode.com/t/what-is-wrong-with-this-code/10809 "2021-11-09T20:40:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheJaky](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/thejaky/32/5711_2.png) [@TheJaky](https://forum.makecode.com/u/TheJaky)\
**Post date:** [November 9, 2021, 8:40pm UTC](https://forum.makecode.com/t/what-is-wrong-with-this-code/10809/1 "2021-11-09T20:40:47Z")

</div>

What is wrong with this code?

![Screenshot 2021-11-09 2.29.36 PM](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/3/3e2014c6dfeebea62500ee88d8380ea1b4f27bc1.png)

To clarify, the AnimArray variable is an array of the 5 most important animations in my game.

---

<div class="post-metadata">

**Author:** ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)\
**Post date:** [November 9, 2021, 8:53pm UTC](https://forum.makecode.com/t/what-is-wrong-with-this-code/10809/2 "2021-11-09T20:53:26Z")

</div>

You cannot change the color of an array of images (array of images == animation block) so you must iterate over every frame in the animation individually.

---

<div class="post-metadata">

**Author:** ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)\
**Post date:** [November 10, 2021, 4:35pm UTC](https://forum.makecode.com/t/what-is-wrong-with-this-code/10809/4 "2021-11-10T16:35:18Z")

</div>

For example:  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/8/8ecd74094d4fe5f8077dcf9e9c1f1d9f11275930.png)  
Yours would have more if statements, etc. but it will still have a nested for loop like this.

---

<div class="post-metadata">

**Author:** ![TheJaky](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/thejaky/32/5711_2.png) [@TheJaky](https://forum.makecode.com/u/TheJaky)\
**Post date:** [November 10, 2021, 8:13pm UTC](https://forum.makecode.com/t/what-is-wrong-with-this-code/10809/5 "2021-11-10T20:13:11Z")

</div>

how do you change the “value” in the for element blocks to something else (like the image variable [variable???] in the example)

---

<div class="post-metadata">

**Author:** ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)\
**Post date:** [November 11, 2021, 12:11am UTC](https://forum.makecode.com/t/what-is-wrong-with-this-code/10809/6 "2021-11-11T00:11:17Z")

</div>

Right click the “value” variable drag-out thingy:  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/b/b6d9657edf8bbe1cb2d52317ca96b1519d99e376.png)  
You can choose for it to be an existing variable or rename it. Note that this list isn’t sorted for some reason and doesn’t look as nice…not sure why.

---

<div class="post-metadata">

**Author:** ![TheJaky](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/thejaky/32/5711_2.png) [@TheJaky](https://forum.makecode.com/u/TheJaky)\
**Post date:** [November 11, 2021, 6:12pm UTC](https://forum.makecode.com/t/what-is-wrong-with-this-code/10809/7 "2021-11-11T18:12:09Z")

</div>

OK

**![[animate output image]|270px;x156px;](https://lh4.googleusercontent.com/qhCtTaQoPo1P_vyyIOb-yn2OjjrivuWeKkEXAcNY_pMJhB7YJzfPdDm7Mn7ao8TpEj-jDijK36XOBtMQEBe11DNE1QvW-a_QDyMZijZt0SI2WLNwHVYPMhidqV0xrxprsDA9DDwUgKA)**
