This video will go over detecting if a player is sneaking using commands. The commands used can either run a command every tick that a player is sneaking, or run a command once when a player begins sneaking.
Commands used to detect every tick:
/execute as @a[scores={sneaking=1},tag=!sneaking] run tag @s add sneaking
/scoreboard players set @a sneaking 0
/execute as @a[tag=sneaking] run say I am sneaking
/tag @a remove sneaking
Commands used to detect once:
/execute as @a[scores={sneaking=0}] run tag @s remove sneaking
/execute as @a[scores={sneaking=0}] run tag @s remove alreadysnuck
/execute as @a[scores={sneaking=1},tag=!sneaking] run tag @s add sneaking
/scoreboard players set @a sneaking 0
/execute as @a[tag=sneaking,tag=!alreadysnuck] run tag @a add alreadysnuck
/say I am sneaking