Ui showing z position of an object in scene c#

Im trying to script ui to show the z position of an object in game, im not sure how to this exactly , i tried and edited this script with no success so far, im getting “17,27 cannot inplicitly convert type float to string” error.

I think there is a problem converting text to a number and the component to connect the object whose z will be taken.

I am basicly trying the text to show the z value of object in the scene so any solutions or toughts would be much appreciated.

Regards

using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class SomeScriptName : MonoBehaviour
{
	public Text scoreText;
	
	void Start()
	{
		scoreText = GetComponent<Text>();
	}
	
	void Update()
	{
		scoreText.text = transform.position.z;
	}
}

From Digzou’s comment

  using UnityEngine;
  using UnityEngine.UI;
  using System.Collections;
  
  public class Score : MonoBehaviour
  {
      public Text scoreText;
      public float realz = 0f;
      void Start()
      {
          realz = transform.position.z - 90; //Setting  your value here.
          scoreText = GetComponent<Text>();
      }
      
      void Update()
      {
          scoreText.text = realz.ToString();
      }
  }

using UnityEngine;
using UnityEngine.UI;
using System.Collections;

 public class Score : MonoBehaviour
 {
     public Text scoreText;
     public float realz = 0f;
     void Start()
     {
         realz = transform.position.z - 90; //Setting  your value here.
         scoreText = GetComponent<Text>();
     }
     
     void Update()
     {
         scoreText.text = realz.ToString();
     }
 }