How to change color via script

im trying to change the color of some text using the script, however it dosent see to be working, here is my code

GetComponent(Text).color =;

i am getting multiple issues because of this code, please could someone explain why.

Use the generic form instead. The non-generic only returns an object of type Component, which doesn’t have a color property.

Like so:

GetComponent<Text>().color =;

GetComponent(Text) returns a Component.
You need to cast it back to Text type.


You can also simply use the generic implementation


Which will return the component as the type it is given (Text).