- Home /
Question by
DevonJS · Feb 25, 2011 at 05:45 PM ·
syntax-errordeclaration
Minus not working?
I just need someone to look at my script other than me....
var spawnerhealth = "300"; var damagefromexplosion = "50"; var thisbox = Transform;
function OnTriggerEnter ( hit : Collider) { if(hit.gameObject.tag == "fireball") { spawnerhealth -= damagefromexplosion; } }
function Update () {
if(spawnerhealth == 0) { Destroy(gameObject); }
}
it says that -= is an invalid string. help?
Comment
Answer by Demigiant · Feb 25, 2011 at 06:10 PM
You set spawnerhealth and damagefromexplosion as string :P
Should be
var spawnerhealth = 300;
var damagefromexplosion = 50;
Answer by robert 4 · Feb 25, 2011 at 06:11 PM
you cannot assig -= to there it is totally wrong spawnerhealth you have alrady assignent some value eg var add : int;
add -= 1;
Your answer
![](https://koobas.hobune.stream/wayback/20220613110251im_/https://answers.unity.com/themes/thub/images/avi.jpg)