1

Please help me with this my variable (Score) is not changing when i hit the enemy. Programming: Scatch MIT

link for file https://scratch.mit.edu/projects/840044224

I expect it to change when i hit the enemy with bulet

2 Answers2

3

The forever loops that are supposed to increase score, are both under a when green flag clicked hat block. That means they only work for the main instance of their sprite; not for clones.

Original scoring loop

Both the bullets and the enemies are clones; the main instances of the sprites are invisible and do not move. That means the touching block will never detect a collision.

One solution is to replace the when green flag clicked hat block by a when I start as a clone hat block.

enter image description here

Another possibility is to remove the entire loop, and simply increase the score as you delete the enemy clone.

enter image description here

Ruud Helderman
  • 10,563
  • 1
  • 26
  • 45
1

In the costume 2 sprite, put an if statement, if the costume 2 touches costume 3, increase the score by 1 as seen here:

screenshot

You can see a modified version of the game.

Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
khartist
  • 11
  • 2