# Problem with code

**URL:** <https://forum.makecode.com/t/problem-with-code/24134>\
**Category:** Help\
**Tags:** game, extension\
**Created:** [November 10, 2023, 11:40pm UTC](https://forum.makecode.com/t/problem-with-code/24134 "2023-11-10T23:40:35Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![ARealNormalWanderer](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/arealnormalwanderer/32/11787_2.png) [@ARealNormalWanderer](https://forum.makecode.com/u/ARealNormalWanderer)\
**Post date:** [November 10, 2023, 11:40pm UTC](https://forum.makecode.com/t/problem-with-code/24134/1 "2023-11-10T23:40:35Z")

</div>

So I am currently making a Backrooms game and there is a 0.1 percent chance of a blackout event, so each BE (Blackout Event) smilers are supposed to spawn in certain positions (maybe I’ll randomized it one day) but each time a choose a specific spot for it, it always spawns at the beginning (not to mention keeps spawning them each 2 - 3 seconds) and I need help with it.

Here is my game: [https://arcade.makecode.com/S31494-81270-36504-30984](https://arcade.makecode.com/S31494-81270-36504-30984)

---

<div class="post-metadata">

**Author:** ![randomuser](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/randomuser/32/32505_2.png) [@randomuser](https://forum.makecode.com/u/randomuser)\
**Post date:** [November 11, 2023, 12:29am UTC](https://forum.makecode.com/t/problem-with-code/24134/2 "2023-11-11T00:29:16Z")

</div>

Welcome! Good luck with you game, IDRK how backrooms works here so I’m not sure how t help.

---

<div class="post-metadata">

**Author:** ![\_jupiter](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/_jupiter/32/28012_2.png) [@\_jupiter](https://forum.makecode.com/u/_jupiter)\
**Post date:** [November 14, 2023, 5:08pm UTC](https://forum.makecode.com/t/problem-with-code/24134/3 "2023-11-14T17:08:56Z")

</div>

0.1 percent out of what?

---

<div class="post-metadata">

**Author:** ![ADM\_F](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/adm_f/32/19808_2.png) [@ADM\_F](https://forum.makecode.com/u/ADM_F)\
**Post date:** [November 14, 2023, 5:09pm UTC](https://forum.makecode.com/t/problem-with-code/24134/4 "2023-11-14T17:09:04Z")

</div>

I think that the problem is that you using the wrong Block for setting position

try using this one  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/b/b6d3443e3ad04e80ad6358a1f8c4639fa11ac69e.png)

The blue one sets the exact position of a sprite but this one places it on a certain tile

---

<div class="post-metadata">

**Author:** ![ADM\_F](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/adm_f/32/19808_2.png) [@ADM\_F](https://forum.makecode.com/u/ADM_F)\
**Post date:** [November 14, 2023, 5:09pm UTC](https://forum.makecode.com/t/problem-with-code/24134/5 "2023-11-14T17:09:09Z")

</div>

Also does the Sprite Follow a path or just Slam its head into a wall I made a horror game very similar to this and I had a problem like that but I was able to fix it with an extension

“Ai” extension  
**[https://github.com/jwunderl/arcade-tilemap-a-star](https://github.com/jwunderl/arcade-tilemap-a-star)**

if you need any help with using this extension just msg me again!

---

<div class="post-metadata">

**Author:** ![YuHayate](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/yuhayate/32/8275_2.png) [@YuHayate](https://forum.makecode.com/u/YuHayate)\
**Post date:** [November 14, 2023, 5:09pm UTC](https://forum.makecode.com/t/problem-with-code/24134/6 "2023-11-14T17:09:17Z")

</div>

thats because you call it every 1ms so on average once per second  
what you can do is to change it to a `on game update every (1000ms)` block  
or a

```auto
game.onUpdateInterval(1000, function () {
	
})

```

---

<div class="post-metadata">

**Author:** ![ChimbroDaPro](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/chimbrodapro/32/15852_2.png) [@ChimbroDaPro](https://forum.makecode.com/u/ChimbroDaPro)\
**Post date:** [December 28, 2023, 6:44pm UTC](https://forum.makecode.com/t/problem-with-code/24134/7 "2023-12-28T18:44:31Z")

</div>

Uh… 100?

---

<div class="post-metadata">

**Author:** ![YuHayate](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/yuhayate/32/8275_2.png) [@YuHayate](https://forum.makecode.com/u/YuHayate)\
**Post date:** [December 28, 2023, 9:55pm UTC](https://forum.makecode.com/t/problem-with-code/24134/8 "2023-12-28T21:55:30Z")

</div>

out of time i guess

---

<div class="post-metadata">

**Author:** ![Sarge](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/sarge/32/19590_2.png) [@Sarge](https://forum.makecode.com/u/Sarge)\
**Post date:** [January 2, 2024, 7:19pm UTC](https://forum.makecode.com/t/problem-with-code/24134/9 "2024-01-02T19:19:58Z")

</div>

Maybe it was meant as 0.1% chance every game tick
