I have come up with an idea for a map, but I couldn't implement it because I'm not strong in command blocks. I want to make it so that when a player holds a clock in their active hand and presses the mouse button (either right or left, it doesn't matter as long as it works), their Y-coordinate increases by +20 blocks, and upon subsequent pressing of the same clock, their Y-coordinate decreases by -20 blocks, and so on. It is essential that this works specifically for the player who activated the command.
I thought of implementing this through a scoreboard, like when a player with a clock in hand presses the mouse button, they are assigned scoreboard 1, and this player is teleported up by 20 blocks. Upon subsequent mouse clicks with the same clock, they are assigned scoreboard 2, and this player is teleported down by 20 blocks, after which the scoreboard is reset specifically for this player. I wanted it to work consistently, but I couldn't make it happen.
Minecraft version 1.18.2, Java.