My intention is to click on the message and then click again to delete the message. So I put an infinite repetition block, but only once. what is the reason?!
To toggle between two different onActivate events, you can place them into functions to change the behaviour whenever the man is clicked.
How the code works
- The function bindSpeakOn creates an onActivate event for man-item. When the man-item is clicked, the man says something and the function bindSpeakOff is triggered.
- The function bindSpeakOff creates an onActivate event for man-item, which overwrites the previous onActivate event. When the man-item is clicked, we remove the phrase and the function bindSpeakOn is triggered.
Outside of the two events we place one bindSpeakOn function block to set the first event when the scene starts.
I hope that this code can help you!