Need Help with Health system not working.

Error: Assets/Health.cs(29,42): error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement

Code:

using UnityEngine;
using System.Collections;

public class Health : MonoBehaviour {

public int MaxHealth;
public int MinHealth;
int CurrentHealth;

// Use this for initialization
void Start () {

	CurrentHealth = MaxHealth;
}

// Update is called once per frame
void Update () {

	if(CurrentHealth <= MinHealth){
	Destroy(GameObject);
		
	}
}
	
public void Damage(int dmgAmount)
	{
	
	CurrentHealth - dmgAmount;
		
	
	if(CurrentHealth <= MinHealth)
	CurrentHealth = 0;
	Destroy(GameObject);
	}
	
	
	}

CurrentHealth - dmgAmount is giving you your issue.
Whilst im at it. Your checking something unnescarely in your update wich is checking if the player has died. But you’ve got it in your void Damage() aswell so why check it twice right :slight_smile:

Keep in mind you can always put comments in your code by using //COMMENT or /COMMENT/

Example how it would be done :

using UnityEngine; 
using System.Collections;

public class Health : MonoBehaviour {
	
	public int MaxHealth; 
	public int MinHealth = 0; 
	public int CurrentHealth = 100;

	// Use this for initialization
	void Start ()
	{
		CurrentHealth = MaxHealth;
	}

	// Update is called once per frame
	void Update ()
	{

	}

	public void Damage(int dmgAmount)
	{

		//Deal damage to player
		CurrentHealth -= dmgAmount;

		//Check if player's health is below 0 (MinHealth)
		if(CurrentHealth <= MinHealth)
		{
			CurrentHealth = 0;
			Destroy(this.gameObject);
		}

	}

}