I really need help with this.

Good day all, i have used alot of time by figuring this out. And it will simply not work. Hope someone in here can help :slight_smile:

The problem: I want my enemy gameObject to loose Health when i click on it and when 0, then die.
This is my script.

54994-code.jpg

  • I can see that it registers the ColliderBox , but when i click it will not loose health.

First of all you seem to write your code in UnityScript. Are you sure this code is in a “.js” file?

Second, almost all programming languages are case sensitive. So casing matters. “update” is not the same as “Update”. You should rename your method.

Another thing that isn’t an actual error but you should be more consitent when naming your variables. There are different conventions. It doesn’t really matter which you use as long as you stay consistent. “health” and “TakeDamage” is not consistent ^^. “takeDamage” would be better.

I found the problem… It was an error in the word GameObject. It should have been GameObject not gameObject. Damn… :smiley:

(First time coding for real, so i guess i’ll learn by my mistakes :D.