Cannot read properties of null (reading 'fields')

So I have a small problem with this code, but i don’t know what. above is the error message displayed, and here is relevant code:

image

here is the link: https://arcade.makecode.com/S63143-69579-47823-00751

4 Likes

When you press A it runs all the code in the On A Pressed block before it runs the code in On Start. This means that the sprite “link” doesn’t exist yet when the code runs, which causes an error. You need to make sure that the link sprite exists before you try to do things to it. You can do this by putting the “link” variable straight into an IF block. The IF block will only run if the “link” sprite exists:

2 Likes

kaboom

thanks guys.

1 Like