State Machine loading scripts for each state [C#]

I coded a State class and a StateMachine class. Each State enables/disables a script when active/inactive.

The script name has to be specified in the State constructor, but from there I'm not sure I'm doing thing correctly:

component = GameObject.Find(strTagOrGameObject).GetComponent(); component.enabled = true;

I have an error, it tells me "component" has not "enabled" member...

Is my algo wrong, or what am I missing ? How do I get a script by its name (or any other parameter) so I can dynamically enable/disable it ?

I'm programming this state machine so it can be used by me and my schoolmate easily to code a lot of QTEs...

This may seem silly, but try adding a debug.log statement and check to see if the object exists.
if the object equals null then give the log reference.

Component does not have an ‘enabled’ flag. Many components seem to because they inherit from Behaviour, which does.

You can use GetComponent() to get components of a specific type.

For example, let’s suppose you have a custom component class, MyComponent

In JavaScript:

    var foo = GameObject.Find("SomeName").GetComponent(MyComponent);

In C#:

    MyComponent foo = GameObject.Find("SomeName").GetComponent();