idea for a script of a gameobject with different types/roles

Hey i have about 6 gameobjects that serve different roles in my game and i want to have the same script attached to them since they will act the same but have certain differences. I was thinking of having different classes for each role in the script. But since Unity will only access the class that bears the same name as the script i have reconsidered it.

How should i do it? I was looking up enums but i am unsure of how they work. Do you guys have any idea on how i should do? I wanna avoid having to make different scripts for each different gameobject, considering they will play like almost the same. The differences is in the way they move, interact with other objects and their position in the gameworld.

If you dont want to use inheritance or abstraction (would require each role having its own class inheriting from a general parent.

Then i would probably use an enum.

public enum RoleType
{
    Knight,
    Ranger,
    Mage
}

public class Character : Monobehaviour
{
    public RoleType; // Set this value in the inspector for each gameobject
    
    private void SomeAction()
    {
        switch(RoleType)
        {
            case Knight :
                DoKnightActions();
                break;
            case Ranger :
                DoRangerActions();
                break;
            case Mage :
                DoMageActions();
                break;
        }
    }
}

One good way is to create certain behaviors with inherited classes.
For example:
You have a monobehaviour script called VehicleController and in that a class called AIBehaviour, and have sub classes called CarMovement and MotorcycleMovement. They have virtual and override functions that you can call in udate or fixedupdate or however you want. It would look like this:

More info on inheritance: Inheritance | Microsoft Learn