Search code examples
mit-scratch

How to stop a clone from inheriting a message


I have this code:

code

But whenever the shoot message is sent to the bullet sprite, and there is a clone on the stage that hasn't hit it's target yet, the clone will be sent back with the go to x: (xOfTower) y: (yOfTower) block. Is there some way to prevent a clone from receiving a message while the real sprite does?


Solution

  • Clones have their own copy of local variables!

    To solve this problem you can add a new variable but be sure to check 'For this sprite only'. Otherwise there will only be 1 variable.

    enter image description here

    Now a new variable will be created for each clone. Give the variable a value to label it as clone and add a guard on your message action.

    scratch code