# Tilemap glitch where it freezes mid way

**URL:** <https://forum.makecode.com/t/tilemap-glitch-where-it-freezes-mid-way/9767>\
**Category:** Arcade\
**Created:** [August 26, 2021, 2:40pm UTC](https://forum.makecode.com/t/tilemap-glitch-where-it-freezes-mid-way/9767 "2021-08-26T14:40:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![breakingboredomloops](https://avatars.discourse-cdn.com/v4/letter/b/dc4da7/32.png) [@breakingboredomloops](https://forum.makecode.com/u/breakingboredomloops)\
**Post date:** [August 26, 2021, 2:40pm UTC](https://forum.makecode.com/t/tilemap-glitch-where-it-freezes-mid-way/9767/1 "2021-08-26T14:40:17Z")

</div>

Hi! I have found this forum so helpful and I’m very grateful.  
I am stuck on this game. Once the end of the third tilemap is reached, the game just freezes. Why?

Less significant, but still a glitch, is the projectiles on tilemap lv 2. They appear randomly after the enemy is destroyed. Is there a way to turn them off?

> **[Levels of tilemaps](https://arcade.makecode.com/19002-41458-89404-48132)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

**Author:** ![GKcode](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/gkcode/32/4885_2.png) [@GKcode](https://forum.makecode.com/u/GKcode)\
**Post date:** [August 27, 2021, 2:44pm UTC](https://forum.makecode.com/t/tilemap-glitch-where-it-freezes-mid-way/9767/3 "2021-08-27T14:44:17Z")

</div>

> [@breakingboredomloops](#):
>
> Once the end of the third tilemap is reached, the game just freezes. Why?

I’m still working on it

---

<div class="post-metadata">

**Author:** ![GKcode](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/gkcode/32/4885_2.png) [@GKcode](https://forum.makecode.com/u/GKcode)\
**Post date:** [August 27, 2021, 2:44pm UTC](https://forum.makecode.com/t/tilemap-glitch-where-it-freezes-mid-way/9767/4 "2021-08-27T14:44:05Z")

</div>

Hi!

> [@breakingboredomloops](#):
>
> Less significant, but still a glitch, is the projectiles on tilemap lv 2. They appear randomly after the enemy is destroyed. Is there a way to turn them off?

Yes

The problem is this:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/c/c1423c3f64db1bb2f9fd664176b4738cc4606f3c.jpeg)  
After mySprite2 is destroyed, the sprite variable mySprite2 doesn’t exist anymore.  
So if mySprite2 doesn’t exist, the [set (projectile) follow (mySprite2) with speed (100)] block doesn’t work because mySprite2 doesn’t exist.

Here is the fixed one:

> **[Levels of tilemaps](https://arcade.makecode.com/43190-94756-07795-44425)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

**Author:** ![breakingboredomloops](https://avatars.discourse-cdn.com/v4/letter/b/dc4da7/32.png) [@breakingboredomloops](https://forum.makecode.com/u/breakingboredomloops)\
**Post date:** [August 30, 2021, 2:11pm UTC](https://forum.makecode.com/t/tilemap-glitch-where-it-freezes-mid-way/9767/5 "2021-08-30T14:11:33Z")

</div>

Cheers for that support.  
The projectile bug makes sense now.  
However, the freeze still happens at this point.

 ![Screen Shot 2021-08-29 at 7.37.58 pm](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/5/520219dd5626c2c6c197686cab877bb6e9513a0a.png)

---

<div class="post-metadata">

**Author:** ![breakingboredomloops](https://avatars.discourse-cdn.com/v4/letter/b/dc4da7/32.png) [@breakingboredomloops](https://forum.makecode.com/u/breakingboredomloops)\
**Post date:** [August 30, 2021, 5:04pm UTC](https://forum.makecode.com/t/tilemap-glitch-where-it-freezes-mid-way/9767/6 "2021-08-30T17:04:39Z")

</div>

@GKcode  
Thanks for the ideas mate!  
I took inspiration from them and got the code to work without the custom function that caused the bug. It wasn’t really needed anyway.

> **[tilemaps lvs fixed](https://arcade.makecode.com/65149-06026-45222-50726)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.
