I keep getting error code 981 and I really dont know what it is
share code pls
Welcome, @Davida !
It sounds like you’re trying to run a project on a hardware device. Error code 981 is called cast on undefined, where you are using a variable that does not have a value.
Common hardware error codes are listed here:
As @Luke mentioned, if you need further help, then share your project with us so that we can try to give more specific assistance.
@Davida To share code, use the share button when you have the project open.
MakeCode will give you a web link to your published project after you have shared it. You can use that link to share your project with us.
Is this ok?
Its not done yet i still havent figured out the problem
I think i have figured the problem but it still sometimes occures when I destroy two asteroids at the same time.
Updated code: https://makecode.com/_e1kfmeV8bdgE
Hi Davida,
In your code detecting the projectile’s collision with the asteroid, it looks like there may be a mix-up between sprite
, otherSprite
, and asteroid
. Here’s the current code:
In this event, sprite
is the sprite of kind Enemy (in other words, the asteroid) and otherSprite
is the projectile. Asteroid
is a variable you created earlier, which will likely be set to the last Asteroid you spawned, but is not necessarily the asteroid in the collision.
This code destroys sprite
, which is the asteroid in the collision. I’m guessing you actually want to destroy otherSprite
, which is the projectile. The code then tries to change the status bar on Asteroid
, which may or may not be the asteroid you just destroyed (that would cause the issue you’re seeing). Instead of this, I expect you want to change the status bar on sprite
(the asteroid actually involved in the collision).
In other words, something like this:
Does that resolve the issue you’re seeing?
Thank you, this very much resolves the issue.
Glad to hear it