Why can't I drag a GUI Text object onto a GUIText variable?

Hello,

I have driving simulator in which I’m trying to display a vehicle speed via a GUI Text controlled by a script.

In the vehicle controller script, I declare:
public GameObject vehicle; (this contains the RigidBody to get the speed)
public GUIText speedDisplay;
public float speedValue;

then in the update loop, I have:
speedValue = vehicle.GetComponent().velocity.magnitude;
speedDisplay.text = speedValue.ToString();

All of this seems to work fine, BUT THEN:

In the inspector while I can see my three variables and am able to drag my vehicle game object and see the speed value change at run time, Unity won’t let me drag any Text object from the hierarchy onto the GUI Text variable (the one that says Speed Display below and None (GUI Text) in the inspector.

107430-inspector.png

107432-hierarchy.png

My Text is part of a canvas and I’ve tried putting the text and canvas in different spots in the hierarchy with no success. I don’t know what I’m doing wrong. Any suggestions?
Thank you very much for your help.
Cheers, Pascal

The GUIText class is an ancient relic from times before OnGUI was even a thing. OnGUI is now considered the legacy GUI system. The GUIText class is way beyond that and has no connection to the new uGUI system. You probably ment to use the Text class. You should declare your variable as UnityEngine.UI.Text.

If you have a using UnityEngine.UI; at the top of your script your can declare your variable like this:

public Text speedDisplay;