Display rigidbody speed to a world space canvas text

Im trying to display the speed value given by this script to a world space canvas as just text but I cant for the life of me figure out how heres my speed code

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

public class speed : MonoBehaviour {

	void Update () {
		var speed = GetComponent<Rigidbody>().velocity.magnitude;
		Debug.Log("speed:" + GetComponent<Rigidbody>().velocity.magnitude + "m/s"); 
	}
}

Help would be much appreciated

  1. Add a Text component to your scene.
  2. Get a reference to this Text component. E.g.: Add a “public Text myText;” and serialize it using the scene editor.
  3. After “var speed = …”, have “myText.text = speed.ToString();”
    Done.

Worked great thanks!