Need help with my damage/health scripts

I am currently having two errors with my C# damage and health scripts. This is the health script error that I am getting “Identifier expected error”. The error that I am getting in my damage script is “a namespace can only contain types and namespace declarations error”. I’m still fairly new with using C# so I am unsure whats causing the errors. Any thoughts would be a great help.

This is my health script:
577073–20570–$HealthController.cs (979 Bytes)

And damage script
577073–20571–$monster.cs (427 Bytes)

In monster.cs, your OnCollisionEnter method is outside of the monster class, which won’t work. So, you need to move the brace that ends the class (currently, after the “public GameObject hit;” line) to the end of the file.

Okay that fixed my namespace error thank you.

Edit I’ve fixed my identifier expected error in HealthController.cs by removing the Collin but now i am getting a type expected error?

here’s what my new piece of HealthController.cs looks like:

void ApplyDamage (health damage){
		if (health < 0)
			return;
		
		health -= damage;
		if (health < 0)
			
		Destroy.GameObject (Sphere);
		}

Well, you haven’t specified the data types of your health and damage arguments. I’d guess you want something like:

void ApplyDamage (int health, int damage)

That seems to have fixed my error thank you very much for your help.