/

/return

op 2Technical

/return stops the current function immediately and gives the caller a result, which /execute store or /execute if function can act on. It turns functions into something much closer to real subroutines.

Command1 to fix
7
/return
  • Value is required.
Press C to copy

Value is required.

Examples

  • Return success
    /return 1
  • Return a count
    /return run execute if entity @e[type=zombie]

Common questions about /return

What does return fail do?

It ends the function with no result at all, so an execute if function wrapped around it counts as failed rather than returning zero.

Does /return stop every function in the chain?

No. It ends only the function it is written in. Whatever called that function carries on from the next line, receiving the returned value.