Updated:
1. Setup: run once
/scoreboard objectives add points dummy "Points"
/scoreboard objectives setdisplay sidebar points
/team add red
/team add blue
/team modify red color red
/team modify blue color blue
/team modify red friendlyFire false
This creates a score to count points and two colored teams. friendlyFire false stops teammates hurting each other (see the team command).
2. Start: run when the button is pressed
/team join red @a[tag=red]
/team join blue @a[tag=blue]
/gamemode adventure @a
/clear @a
/effect clear @a
/scoreboard players set @a points 0
/spreadplayers 0 0 10 50 true @a
/give @a minecraft:wooden_sword
/title @a title {"text":"Go!","color":"gold"}
/playsound minecraft:entity.player.levelup master @a ~ ~ ~ 1 1
- Adventure mode: players cannot break the arena.
- Empty inventories and effects: nothing carries over from the last round.
- Random spawns:
truekeeps teams together (see spreadplayers). - Title and sound: make the start obvious (see title and playsound).
In command blocks, link these with chain command blocks so they run in order (see the command block guide). Add a 3, 2, 1 countdown before the start, or let players pick the game with a vote.
3. During the game: run all the time
/execute as @a[team=red] at @s if block ~ ~-1 ~ minecraft:gold_block run scoreboard players add @s points 1
/execute if entity @a[scores={points=10..}] run title @a title {"text":"Game over!"}
In a repeating command block these run every tick. The first gives red players a point while they stand on gold, and the second checks whether anyone reached 10. For kill counts and timers see the scoreboard minigame guide, and for a countdown bar see bossbar.
The first line keeps adding points every tick while a player stands there. To count only once, tag the player and exclude the tag afterward. For races use the stopwatch command; for kill goals the mob kill counter; for lives the death counter.
4. End and reset
/tp @a 0 64 0
/gamemode adventure @a
/clear @a
/effect clear @a
/team leave @a
/scoreboard players reset @a points
/kill @e[type=minecraft:item]
Send everyone back to the lobby, reset inventories, effects, teams and points, and clean up dropped items, so the next round can start right away.
On Bedrock
- Bedrock has no /team. Split teams with tags instead (
/tag @a[...] add red). - Write
/effect @a clearand/title @a title Go!. - Scoreboards, /spreadplayers and the new /execute syntax (1.19.50+) all work.
Common problems
- Commands run over and over: check impulse vs repeat. Start commands belong in an impulse block that runs once.
- Chat fills with command output:
/gamerule command_block_output false(commandBlockOutputon 1.21.10 and older). - Bystanders get caught up: tag the players taking part and use
@a[tag=player]instead of@a(see the tag command).
Common questions
- Can non-operators start the game? Yes, a button wired to a command block works for anyone. For chat menus, use /trigger.
- Should I use a data pack? Command blocks are fine for small games. As commands pile up, functions are easier to manage.
- Can the arena be reused? Yes, with the reset commands. For games that break the arena, /clone a saved copy back in.
Check your command
The Command Error Doctor checks common syntax mistakes in your browser.