EntitiesBedrockEducation
/testfor
Checks whether any entities match the given target/selector and reports the count to the command output — used in command-block contraptions to drive comparators. On Java this pattern is done with /execute if entity instead.
Syntax
Parameters
- victim
- entity selector
- Entities/players to test for.
Examples
Count players within 10 blocks (powers a comparator).
Detect whether any creepers exist.
Permission level
/testfor requires Cheats (op level 2). In single-player you need the world's "Allow Cheats" toggle on. On a multiplayer server you need to be opped — see /op.