C# Null Reference exception with GetComponents()

Hey, new to Unity!

So I’m trying to grab all the components of a specific type from a GameObject and I get a null reference exception due to the FireScript array not getting assigned an instance. I know these components exist since the spawner is instantiating enemies with the correct behavior. (I’m trying to get them to fire in sync at the moment)

So what could be going on here?

FireScript[] _fireScripts = _enemy.GetComponents(typeof(FireScript)) as FireScript[];
for (int i = 0; i < _fireScripts.GetLength(0); ++i) // Null reference exception upon calling for the array's length.
    _fireScripts*.fireTimer += elapsedActiveTime;*

Try this:

FireScript _fireScripts = _enemy.GetComponents();