How to Detect if a Player is Running in Minecraft
Minecraft Java Edition 1.21+ and 26+ (Scoreboard + Command Blocks)
In this tutorial, you will learn how to detect if a player is running in Minecraft Java Edition 1.21+ and 26+ using a scoreboard and command blocks. This method is perfect for custom maps, automatic triggers, effects, events, and advanced mechanics that activate when the player starts sprinting.
Start by creating a scoreboard that adds points when the player runs
scoreboard objectives add running custom:sprint_one_cm
After that, place a Repeat command block set to (Always Active) with the following command
execute as @a if entity @s[scores={running=1..}] run say Running!
In the same direction as the Repeat command block, place a Chain command block (connected to the Repeat block) and set it to Always Active with the command below
execute as @a if entity @s[scores={running=1..}] run scoreboard players set @s running 0
The idea is to detect if the player ran through the Repeat command block and run a command; in this case we run say
And in the Chain command block we reset the score, indicating that the player may be standing still and stop running the say command