execute @a[tag=AFK] ~ ~ ~ scoreboard players operation @s AFKDetection += @s Walking
execute @a[tag=AFK] ~ ~ ~ scoreboard players operation @s AFKDetection += @s Sprinting
execute @a[tag=AFK] ~ ~ ~ scoreboard players operation @s AFKDetection += @s Sneaking
execute @a[tag=AFK] ~ ~ ~ scoreboard players operation @s AFKDetection += @s Jumping
execute @a[tag=AFK] ~ ~ ~ scoreboard players operation @s AFKDetection += @s Flying

scoreboard players tag @a[tag=AFK,score_AFKDetection_min=1] add AFKCancel