How to change a variable from your script by subtracting it from the value of another one.

So right now I have this script, and I’m trying to minus patk from EnemyHealth. However, I get a unexpected symbol “=” error.

GameObject.Find (“BadBoi”).GetComponent ().EnemyHealth - patk = EnemyHealth ;

Can anyone help?

Edit: I was not correct as at first glance, I didn’t notice that you are not getting the component properly and you need to set a variable inside EnemyHealth, likely called health, but since EnemyHealth is a script, you can’t subtract anything directly from it.

EnemyHealth enemyHealth  = GameObject.Find ("BadBoi").GetComponent<EnemyHealth>();

The above will get your enemy health script. Now set health: -= patk;

I have no idea what the name of the health variable is inside EnemyHealth, just assuming it is health. Cheers,