Function not looping [mcfunction]

Function not looping [mcfunction] - Group of People Standing and Talking in a Room

So I am extremely immature and want to create a "poop" function in Minecraft Java edition. The problem is, it's not looping. Here's my idea: When you run the function, it will wait for the one who run it to crouch. When that happens, it should summon a cocoa bean named "poop" and play a sound. After that, it should not summon another item or play another sound unless it is run again. Here's the code I wrote for it:

tag @s[tag=!pooping, name=!Server] add pooping

execute if entity @s[name=!Server] run scoreboard objectives add pooperCount dummy
execute if entity @s[name=!Server] run scoreboard players set count pooperCount 0

execute if entity @s[name=!Server] run execute as @a[tag=pooping] run scoreboard players add count entityCount 1
execute if entity @s[name=!Server] run execute if score count pooperCount matches 2.. run tellraw @s {"text": "Only one person can poop at a time"}
execute if entity @s[name=!Server] run execute if score count pooperCount matches 2.. run tag @s remove pooping

execute if entity @s[name=!Server] run scoreboard objectives remove pooperCount

execute unless entity @a[tag=pooping, scores={Sneak=0..}] run scoreboard objectives add Sneak minecraft.custom:minecraft.crouch_one_cm

execute if entity @a[tag=pooping, scores={Sneak=1..}] run summon item ~ ~-1 ~ {Item:{id:"minecraft:cocoa_beans", Count: 1b, tag:{display:{Name:'{"text":"poop"}'}}}}
execute if entity @a[tag=pooping, scores={Sneak=1..}] run playsound block.stone.break player @s

execute if entity @a[tag=pooping, scores={Sneak=1..}] run scoreboard objectives remove Sneak

# just for testing
say hi

execute if entity @a[tag=pooping, scores={Sneak=0}] run schedule function crab:poop 1s replace

Now what actually happens when I run this code (after reloading)?: The first time I run it: I only say "hi" once, and the Sneak objective is not removed. The second time depends: If I crouched before running it, the poop is summoned immediately and the sound plays, and the Sneak objective is removed. If I didn't crouch, nothing is played or summoned, and the Sneak objective is not removed. In both of these cases, I only say "hi" once.

So I guess my looping technique is wrong.

NOTE: Minecraft Version 1.16.5





Pictures about "Function not looping [mcfunction]"

Function not looping [mcfunction] - Black Screen With Code
Function not looping [mcfunction] - Table Setting for an Event
Function not looping [mcfunction] - From below of Tsam mystery mask with gilded human face and third eye and pig nose and fangs among teeth and golden circles around face and full head of red hair decorated with red hairband adorned with golden skulls






Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

Images: Pavel Danilyuk, Antonio Batinić, Gillian Harrison, ArtHouse Studio