How to inherit from a class that inherits from MonoBehaviour

Im trying to implement a base class such as this:

public class Entity : MonoBehaviour
{
    public float speed = 0.05f;
    public float maxHP = 100f;

    protected float currentHP = 0;

    public float GetMaxHP()
    {
        return this.maxHP;
    }

    public float GetCurrentHP()
    {
        return this.currentHP;
    }

    public float GetSpeed()
    {
        return this.speed;
    }

    public void DamageHP(float damage)
    {
        this.currentHP -= damage;
    }
}

and inherit it from this class:

public class PlayerBehavior : Entity
{

    void Start()
    {
    }

    void Update()
    {
    }
}

and when I try to drag the PlayerBehaviour script to the player, an error pops out:

Can’t add script behaviour AssemblyInfo.cs. The script needs to derive from MonoBehaviour!

@xxmariofer yes Im attaching it to the gameobject, when I attach the entity class it works but not the player

World “Entity” is reserved by Unity for so called “Entity Component System”. So when you inherit from Entity, you inherit not from your Entity, but from ECS Entity. Rename you class name, your resolve name collision somehow.