Convert GameObject in CarControl

I have a script where I have a variable of type:

var Cars: CarControl; 

And I have one GameObject in the Hierarchy called “PickupRed” which possesses the “CarControl” Active scripting.

How do I put the GameObject in Cars? by code?

When I try to put:

Cars = GameObject.Find("PickupRed");

says it can not convert the GameObject in CarControl.

Someone please help me.

I prefer to use FindObjectOfType(“CarControl”) if there is only 1 in the scene, or simply just place the gameobject in question in the exposed variable.

The issue here is that you are getting the type GameObject from the Find function, but your variable is not of that type. You can use GetComponent(“CarControl”) directly after the find/

Cars = GameObject.Find("SomeCar").GetComponent("CarControl");