Return a value
/return 1Ends the function at once and returns 1. Write it in a .mcfunction file without the slash.

/return stops the current function and hands a value back to the command that called it. /return fail makes the call fail instead, and /return run returns the result of another command. It turns functions into reusable checks for /execute if function and /execute store.
/return fail/return run …/return <value>| Argument | Expects | What it does |
|---|---|---|
| value | Whole number | Whole number handed back to the caller; execute if function treats 0 as a failed test. |
/return 1Ends the function at once and returns 1. Write it in a .mcfunction file without the slash.
/return failEnds the function as failed: execute if function does not pass and store success stores 0.
/execute unless entity @s[tag=ready] run return 0Placed at the top of a function, ends it for any executor without the ready tag.
/execute if function mypack:has_key run say Door unlockedRuns mypack:has_key and posts the message only if it returns a value other than 0.
/execute store result score total calc run function mypack:count_mobsWrites the number returned by mypack:count_mobs into the invented holder total of the calc objective.
Fill in the fields, then copy the command.
Command generatorInside a function, return 1 ends the file at once: the lines below it never run. The value goes to whatever called the function. Typed in chat, /function answers "Function ... returned 1". execute if function passes when the value is not 0, and execute store result writes it into a /scoreboard score.
return fail ends the function as a failure, so execute if function fails and store success stores 0. return run runs one command and returns its result, for example return run scoreboard players get @s coins to hand back a score.
execute unless entity @s[tag=ready] run return 0 at the top of a function skips the rest for entities without the tag.✓ Checked in Java Edition 26.3 · updated 2 November 2026
No, the value is a whole number. Multiply the value first, for example by 100, if you need decimals.
They are skipped. The function stops on the /return line, so place it where the work is done or where a check fails.
Type it in the chat with cheats on: /return fail.
Cheats on, or operator level 2.
It is in the official command tree since Java Edition 1.20.