Both roll and value return the picked number as the command result, so /execute store can write it straight into a scoreboard.
Valid for Minecraft 26.1.2. No OP needed: any player can run this form, even in worlds without cheats.
/random is Minecraft's built-in dice roller. Added to Java Edition in 1.20.2, it draws a number from a range you choose and either announces it to the whole server (roll) or shows it only to you (value), with an optional named sequence that makes the draws reproducible for maps and minigames.
The command has three subcommands. roll is the public form: the result is posted in chat as Steve rolled 4 (from 1 to 6), visible to every player, which settles loot splits and turn order arguments on the spot. value picks a number the same way but whispers it to the runner only. reset is the maintenance form: it reseeds one named sequence, or all of them at once, so future draws restart from a known state.
Permissions are unusual for a slash command: plain roll and value need no OP at all, so any player can roll dice in chat even on servers without cheats. The bar rises to permission level 2 (an operator, a command block or the server console) only when a command names a saved sequence, and for every form of reset.
Both roll and value also return the picked number as the command's result, so /execute store result score can write it straight into a scoreboard. That makes /random the cleanest vanilla randomizer: no dropper full of items, no armor-stand spreadplayers tricks, just one command per draw.
The syntax has not changed since the command was added in 1.20.2, so the same generated command works in every version from 1.20.2 to the current release.
Copy any of these as a starting point, or rebuild them in the generator above:
/random roll 1..6Rolls a six-sided die and announces the result to every player in chat. No OP needed./random value 1..100Picks a number from 1 to 100 and shows it only to you. The quiet variant for testing and command chains./random roll 1..6 mymap:diceRolls the die through the saved sequence mymap:dice, so draws are reproducible after a reset. Needs permission level 2./random reset *Reseeds every named sequence in the world at once. Needs permission level 2./random reset mymap:dice 12345 false falseRestarts mymap:dice from seed 12345 with both mix-ins off, so the sequence repeats identically in any world.A plain /random roll is genuinely unpredictable, which is exactly what you want for dice but useless when a map needs randomness it can replay. That is what sequences are for: a sequence is a named generator state saved in the world, and every draw that names it advances that one generator in order. Two command blocks rolling through mymap:dice share the same stream of numbers, and the stream itself can be rewound.
Rewinding is what /random reset does. On its own it reseeds the sequence randomly, useful as a shuffle. With a seed it restarts the sequence from a fixed point, so the next draws are known in advance. The two trailing flags control what else is mixed into the new state: includeWorldSeed folds the world seed in, and includeSequenceId folds the sequence's own id in. Both default to true, which keeps different worlds and different sequences from repeating each other.
For fully deterministic behavior, set both flags to false with a fixed seed: /random reset mymap:dice 12345 false false makes the sequence produce the same numbers in the same order in any world that runs it. That is the backbone of repeatable loot shuffles, identical practice-mode runs and shared puzzle seeds. Because the flags chain in order, includeSequenceId can only be given after includeWorldSeed; the generator above handles that rule for you by writing the first flag as true when you only set the second.
The /random command, added to Java Edition in 1.20.2, draws random numbers from chat or command blocks. It has three subcommands: /random roll picks a number from a range and announces it to every player in chat, /random value picks one quietly and shows it only to whoever ran the command, and /random reset reseeds named random sequences. Both roll and value also return the picked number as a command result, so other commands can capture it.
Not for plain rolls. /random roll 1..6 and /random value 1..100 can be run by any player, even on servers without cheats enabled. Permission level 2 (operator status, a command block or the server console) is only required when you name a saved sequence, for example /random roll 1..6 mymap:dice, and for every form of /random reset.
A sequence is a named, saved random-number generator state, identified by a resource location id such as mymap:dice. Every draw that names the same sequence advances the same generator, which makes the results reproducible: after /random reset with a fixed seed and both mix-in flags set to false, the sequence returns the same numbers in the same order, in any world. Plain rolls without a sequence use unpredictable randomness instead.
Use /execute store result score. For example, /execute store result score @s roll run random value 1..100 writes the picked number into the roll objective for the executing player. random value is the natural variant for this because it does not post anything to public chat, but the stored result is identical with roll.
The range has to cover at least 2 and at most 2,147,483,646 possible values. Both ends are inclusive, so /random roll 5..5 covers a single value and fails with that error, and an open-ended range like 1.. fails the matching too-large check because its maximum defaults to the 32-bit integer limit. Make the maximum at least one higher than the minimum and keep the span under the limit.
Java Edition 1.20.2, released in September 2023. The syntax has not changed since, so commands from this generator work in 1.20.2 and every later version. Bedrock Edition does not have an equivalent /random command.
Want to store rolls in a scoreboard? Or browse more Minecraft tools: