Enemy Combat Script C# Code help needed

Here is a picture of the error Imgur: The magic of the Internet

Here is a picture pf the code Imgur: The magic of the Internet

If you can help thanks so much :slight_smile:

line 48 in your code since you are getting a component of type player health and the variable is of type player health you should put the string to be player health too, that’s what you are doing wrong.
PlayerHealth eh = blah blah (“PlayerHealth”) something like that not enemy. you need to spend a bit of time reading that you are writing

Fixed it - Imgur: The magic of the Internet

Still getting error - http://i.imgur.com/RSE9Zyk.png

The reason it was like that was because I was testing different things that would work.

You should write it like this:

PlayerHealth eh = (PlayerHealth)target.GetComponent(typeof(PlayerHealth));

and do you have a PlayerHealth class?

Because unity doesn’t think you do. Misspelling?

your PlayerHealth class may be private

you need a :

public class PlayerHealth : MonoBehaviour