Does anyone know how to fix this? (Program Error: Cannot read properties of undefined (reading 'fields'))

When i die i keep getting this error, does anyone know how to fix this?

it’s located in the script that generates the world. (the generate function)

1 Like

The issue is that the “game over” stops the forever block from restarting after it’s done, but it doesn’t stop it from completing the code it’s running, so you die and the Wait block is still running in the Forever block, and then the Wait block stops running and it runs the function, but now after the game is over the sprites and the tilemap don’t exist anymore, so trying to do things with them causes an error.
The simple solution is to put the Wait block after the Generate function block, like this: