From Test-Scratch-Wiki
This tutorial shows you how to make a "Score" variable for a game. First, make a variable named "Score". How the game works defines which find of script you will use.
Color Sensing
If you want to detect when touching a particular color, use
when gf clicked forever if <touching color [#0000ff]?> then change [Score v] by (1) end end
If you want to decrease the score when touching a color, change change [Score v] by (1)
to change [Score v] by (-1)
.
Sprite Sensing
To sense when touching another sprite, replace <touching color [#0000ff]?>
with <touching [Sprite v]?>
.
Broadcasts
To use broadcasts, use
when I receive [increase score v] change [Score v] by (1) when I receive [decrease score v] change [Score v] by (-1)