MiniBench

MiniBench / Learn

Project ~6 min read

Build a coin minigame

Time to put the commands together. This little game tracks coins on a live scoreboard, plays a chime each time you collect one, and declares a winner at 10 — all with a few small functions.

1. Set up the score

Create a coins objective, show it on the sidebar, reset everyone to zero, and announce the goal. Run this once to start a game.

# functions/game/setup.mcfunction
scoreboard objectives add coins dummy "Coins"
scoreboard objectives setdisplay sidebar coins
scoreboard players set @a coins 0
title @a title Collect 10 coins!
setup.mcfunction open in the MiniBench editor with the four scoreboard and title commands

2. Collect a coin

This function awards one coin with feedback — a sound and an action-bar message — then checks whether the player has hit 10 and, if so, calls the win function. matches 10.. means "10 or more."

# functions/game/coin.mcfunction
scoreboard players add @s coins 1
playsound random.orb @s
title @s actionbar Coin collected!
execute as @s if score @s coins matches 10.. run function game/win
coin.mcfunction open in the MiniBench editor awarding a coin, playing a sound, and showing a message

3. Win the game

A big title, a triumphant chime, and reset the score so they can play again.

# functions/game/win.mcfunction
title @s title You win!
playsound random.levelup @s
scoreboard players set @s coins 0

4. Trigger it

Test it by hand with /function game/coin a few times — watch the sidebar climb and the win fire at 10. To make it a real game, wire a coin pad: place gold blocks and let a tick.json award a coin when a player stands on one.

# functions/tick.mcfunction (via tick.json)
execute as @a at @s if block ~ ~-1 ~ gold_block run function game/coin

(Add a short cooldown with a tag if you don’t want it awarding every tick while they stand still.)

See it in Minecraft

Export the pack, activate it on a world with cheats, and run /function game/setup then /function game/coin. The Coins objective tracks your score live on the sidebar — and the moment you hit 10, “You win!” fills the screen.

Standing on an open grass field of gold coin pads with a 'Collect 10 coins!' title and the live Coins scoreboard

The gold coin pads in the shot are just a few fills — run this once where you're standing:

# functions/game/build.mcfunction — gold coin pads
fill ~-5 ~-1 ~-5 ~-4 ~-1 ~-4 gold_block
fill ~4 ~-1 ~-5 ~5 ~-1 ~-4 gold_block
fill ~-1 ~-1 ~-1 ~0 ~-1 ~0 gold_block
fill ~-5 ~-1 ~3 ~-4 ~-1 ~4 gold_block
fill ~4 ~-1 ~3 ~5 ~-1 ~4 gold_block

Make it yours

Ship it to Minecraft.

Export the pack, activate it on a world with cheats, and play.

The full round trip