How do I make this work with multiple enemies

I got a script to damage enemies but I only can damage on type of enemy because I put in the component of the script attached to that enemy.
how do I make my script so that I can damage bouth of them.

Enemy that I can damage = ghost

Enemy that I also want to damage = Enemy


as stated by @xxmariofer and @Tsaras multiple ways exist to dealing with such a situation the most commons would be:
1-create a parent class that has the TakeDamage() function then extend it to create ur Enemy and Ghost.
2-create a script called “Status” or Health or such have “TakeDamage” function and assign it to both objects as a second component then simply use it to call the damage function.