Build a shared score counter
This extends your first interaction into a small game system. It uses a Public score so different event calls can read the same state.
Declare and initialize
Section titled “Declare and initialize”- Create a non-Final Public Number Variable named
score. - Add a Plot Start event.
- Follow it with Set Variable assigning
scorethe Number 0.
Event: Plot Start Set Variable: Public Number score ← 0Plot Start initializes each program activation. If you want persistence instead, use a separate Save best score rather than making every current-round value persistent.
Increment on interaction
Section titled “Increment on interaction”Add Player Right Click. Use Set Variable → Operations → Number → Add Numbers (+) with Result Public score, Left Operand Public score, and Right Operand Number 1. Then send a message on Event Target.
Event: Player Right Click Set Variable → Add Numbers (+) Result: Public Number score Left Operand: Public Number score Right Operand: Number 1 Call Method → Event Target → Send Message Message: Shared score: ${public.score}This intentionally uses a shared score: every player contributes to one total. It is not a per-player score just because a Player event changes it.
Compile and test
Section titled “Compile and test”Compile, enter Play, and right-click. Expect the shared total to rise by one per matching event. Minecraft can generate interaction variants; if a game needs a specific held item or interaction context, add the appropriate item/event checks rather than assuming every right-click is the same interaction.
Add a persistent best
Section titled “Add a persistent best”Declare non-Final Save Number bestScore. After incrementing, compare Public score against a Number expression ${save.bestScore ?? 0}. When greater, assign Save bestScore from Public score.
Send Score: ${public.score}; best: ${save.bestScore ?? 0} to display both. Compile and test zero, repeated increments, and reactivation: current score resets while best persists.