Detect if player is above or below entity

I want to be able to have an entity float up if the player is above it, or float down, but I can't find a way to put the y value in a scoreboard. My command I tried is:

execute as @a run execute store result score @s y run data get entity @s Pos[1]```
Continue to help post