How can we achieve the effect with a single line of code?
This is the effect we're aiming for:
If you 're not sure where to find the [change] block, either use the search feature at the top of the block palette, or look under Attributes | Functions in the block palette.
Putting it into practice
In practice, we probably wouldn't wait for the mouse to be clicked; we'd display the increasing score automatically when the required goal has been achieved by the player.
Round the Attribute
The [change] block is not exclusively for the purpose of changing an on-screen attribute; it can be used to change any value that is being used in a game, and sometimes it may be useful to change the value using a special effect. If you're familiar with the Actor | Tweening code blocks, you'll be aware that we can slide, fade, spin and grow actors using various tweening effects, and those effects are the same as those available in the [change] block.
I think the [change] block is a great example of how a complex problem can be reduced to a single line of code without affecting game-play. However, if we don't know that a particular block exists, we can't take advantage of it, which is why I recommend taking time to scan through Stencyl's block palette and check out any blocks that you are not familiar with - there are some gems in there! In most cases, right-clicking on any block and selecting View Help, will display the relevant documentation (you need to be on-line).
Have you found other uses for the [change] block, or are there any little-known code blocks that you have taken advantage of in your games? Let me know in the comments below.