# Why do i get this error when converting to blocks

**URL:** <https://forum.makecode.com/t/why-do-i-get-this-error-when-converting-to-blocks/19861>\
**Category:** Help\
**Created:** [May 12, 2023, 9:39pm UTC](https://forum.makecode.com/t/why-do-i-get-this-error-when-converting-to-blocks/19861 "2023-05-12T21:39:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Samsano](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/samsano/32/8307_2.png) [@Samsano](https://forum.makecode.com/u/Samsano)\
**Post date:** [May 12, 2023, 9:39pm UTC](https://forum.makecode.com/t/why-do-i-get-this-error-when-converting-to-blocks/19861/1 "2023-05-12T21:39:18Z")

</div>

I am making a game that i push to github. I found something similar from Feb 6. 2020.

> [@Oops, something went wrong trying to convert your code](https://forum.makecode.com/t/oops-something-went-wrong-trying-to-convert-your-code/1159):
>
> One day, I was working on a platformer game based on “Jumpy Platformer”(in blocks). I switched in Javascript and it just happened that it said “Oops, something went wrong trying to convert your code.” I didn’t write or do anything. What should I do to fix this and prevent this from happening again.

But my code doesen’t use:

> img’…

i use:

> assets.image’…’

So i don’t get why i get this error. I _could_ just code in TS but i am not that good at it and prefer blocks.

> **Game and github repo**
>
> - [Github](https://github.com/Samsano/LoadingAnimations)
> - [Game](https://arcade.makecode.com/S25596-13141-68543-90295)

If you fix it you can push to github and i’ll look into it 🙂

---

<div class="post-metadata">

**Author:** ![Holmfry](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/holmfry/32/11697_2.png) [@Holmfry](https://forum.makecode.com/u/Holmfry)\
**Post date:** [November 6, 2023, 11:44pm UTC](https://forum.makecode.com/t/why-do-i-get-this-error-when-converting-to-blocks/19861/2 "2023-11-06T23:44:08Z")

</div>

Hello, I appear to be getting this error in my new project as well. I have systematically removed every bit of code one at a time to try and locate the issue. I also removed ALL of the code, same issue, I just cannot go back to blocks. Seems like a bug for sure. I can include anything you need, just let me know.

---

<div class="post-metadata">

**Author:** ![Holmfry](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/holmfry/32/11697_2.png) [@Holmfry](https://forum.makecode.com/u/Holmfry)\
**Post date:** [November 6, 2023, 11:44pm UTC](https://forum.makecode.com/t/why-do-i-get-this-error-when-converting-to-blocks/19861/3 "2023-11-06T23:44:20Z")

</div>

As a follow-up, here is my (JS) code that won’t convert to blocks:

```auto
enum ActionKind {
    Walking,
    Idle,
    Jumping
}
controller.left.onEvent(ControllerButtonEvent.Pressed, function () {
    animation.runImageAnimation(
        mySprite,
        assets.animation`animWalkLeft`,
        250,
        true
    )
})
controller.right.onEvent(ControllerButtonEvent.Pressed, function () {
    animation.runImageAnimation(
        mySprite,
        assets.animation`animWalkRight`,
        250,
        true
    )
})
let enemy: Sprite = null
function spawnEnemy() {
    enemy = sprites.create(assets.image`spriteGhrasto`, SpriteKind.Enemy)
    tiles.placeOnTile(enemy, tiles.getTileLocation(2, 7))
    enemy.follow(mySprite, 20)
}
sprites.onOverlap(SpriteKind.Player, SpriteKind.Enemy, function (sprite, otherSprite) {
    sprites.destroy(otherSprite, effects.spray, 500)
    info.changeScoreBy(1)
    scene.cameraShake(4, 500)
    music.play(music.randomizeSound(music.createSoundEffect(WaveShape.Noise, 5000, 1877, 255, 0, 500, SoundExpressionEffect.Warble, InterpolationCurve.Logarithmic)), music.PlaybackMode.UntilDone)
})
let mySprite: Sprite = null
scene.setBackgroundColor(15)
game.setDialogTextColor(2)
game.splash("Title")
game.setDialogTextColor(9)
game.splash("Dev Name")
scene.setBackgroundColor(9)
scene.createRenderable(scene.HUD_Z, function (target, camera) {
    const w = 40
    const h = 15
    const x = 2
    const y = 2

    // Draw outline
    screen.drawRect(
        x,
        y,
        w,
        h,
        / **black** / 0x0
    )
    // Fill inside rect
    screen.fillRect(
        x + 1,
        y + 1,
        w - 2,
        h - 2,
        / **black** / 0x0
    )
    // Fill it in with whatever else you want
    // text
    let t = info.score()
    screen.print(
        " " + t.toString(),
        x + 2,
        y + 4,
        / **white** / 0x1,
        image.font8
    )
    // or an image
    screen.drawTransparentImage(
        img`
            . . b . b . b
            . b b b b b .
            b . . b . . b
            b . . b . . b
            b b b b b b b
            . b . b . b .
            . . . . . . .
            . . b b b . .
        `,
        // if you want to space text horizontally,
        // note the t.length * image.font8.charWidth to
        // get the width of the text below
        x + 2,
        y + 4
    )
})
tiles.setCurrentTilemap(tilemap`roomBathDoomArena`)
mySprite = sprites.create(assets.image`Ducky`, SpriteKind.Player)
tiles.placeOnTile(mySprite, tiles.getTileLocation(4, 3))
animation.runImageAnimation(
    mySprite,
    assets.animation`animWalkRight`,
    500,
    true
)
game.onUpdate(function () {
    scene.cameraFollowSprite(mySprite)
    controller.moveSprite(mySprite, 50, 50)
})
game.onUpdateInterval(5000, function () {
    spawnEnemy()
})

```

---

<div class="post-metadata">

**Author:** ![Holmfry](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/holmfry/32/11697_2.png) [@Holmfry](https://forum.makecode.com/u/Holmfry)\
**Post date:** [November 7, 2023, 5:54am UTC](https://forum.makecode.com/t/why-do-i-get-this-error-when-converting-to-blocks/19861/4 "2023-11-07T05:54:43Z")

</div>

Update: looks like it may have been a glitch in my actual project; I copy/pasted the code into a new project and was able to switch to block view. I’m going to copy all of my assets across to the new project and hopefully i’ll be g2g.

---

<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:** [November 7, 2023, 6:28pm UTC](https://forum.makecode.com/t/why-do-i-get-this-error-when-converting-to-blocks/19861/5 "2023-11-07T18:28:22Z")

</div>

These kinds of issues are usually to do with an error in one of the system files, like `pxt.json` or such
