someone maybe know why this dont work?

execute as @a if items entity @s weapon.offhand minecraft:gray_dye at @s run tp @e[type=item,distance=..3] @s

Continue to help post