Slider isn't a component???

I am using a slider component for diffrent bars for my GUI. I have a slider(FuelShower) I am trying to access. I create the variable with:

public Slider FuelShower;

_

Which I then assign in Start() using:

FuelShower = GameObject.Find(“FuelShower”).GetComponent();

_

I am getting the error

GetComponent requires that the requested component ‘Slider’ derives from MonoBehaviour or Component or is an interface.
UnityEngine.GameObject.GetComponent[T] ()

from my code.

I do not know what is going wrong, or how to fix it.

@PaintedBirds Are you sure you have added using UnityEngine.UI; at the top of your script and not using UnityEngine.UIElements;?

You’re not getting the Slider component, it should be: FuelShower = GameObject.Find("FuelShower").GetComponent<Slider>();. Also, if the game object is already in the scene, it’s easier to drag it into the variable slot from the inspector as using Find is slow. If this game object is instantiated into the scene, then it’s fine to use in Start to Find the object, but only then it should be used…