Get y position from another game object and then set the value to a Text UI

How do you do this!? Sorry, I’m a newbie. More like noobie.

Anyway,

SITUATION: Player jumps up an endless vertical platform to stay above the ground.

QUESTION: I want to state the distance of player from the ground by getting the player’s y postition and then set the value to a text UI which is on a canvas.

How do you do it? I use C#. Thank you in advance!

create a UI text field in the inspector.
Add this script to the player gameobject

    using UnityEngine.UI; //Add to the top of the C# file

    public Text height; //In the inspector drag the UI text element here

    float playerHeight = this.transform.position.y; //Get the Y position of the player
    
    height.text = playerHeight; //write it to the text element.

Put a script on the UI with two public variables for the player and the floor and one more of type Text to which you assing the Text component with GetComponent() in Start.
Then in Update set its text to player.transform.y - floor.transform.y