My attack scripts don't affect the enemy. can some one help?

To be more specific, my scripts are affecting the player, but they are not effecting the enemy. Here are the scripts.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Attack : MonoBehaviour
{
public float damageAmount = 5.0f;

public void AttackTarget(GameObject target)
{
Fighter targetFighter = target.GetComponent();
if (targetFighter)
{
targetFighter.TakeDamage(damageAmount);
}
}
}

using UnityEngine;
using System.Collections;
using UnityEngine;

public class Fighter: MonoBehaviour
{
public float healthAmount = 0.0f;
public float damageAmount = 0.0f;

public void TakeDamage(float damageAmount)
{
healthAmount += damageAmount;

if (healthAmount >= 100)
{
Die();
}
}

public static void TryDamageTarget(GameObject target, int damageAmount)
{
Health targetHealth = target.GetComponent();

if (targetHealth)
{
targetHealth.TakeDamage(damageAmount);
}
}

private void Die()
{
Debug.Log(“Fighter died!”);
Destroy(gameObject);
}
}

using UnityEngine;

public class MouseClickAttack : MonoBehaviour
{
public Attack attack;

void Update()
{
if (Input.GetMouseButtonDown(0))
{
AttackTarget();
}
}

void AttackTarget()
{
GameObject target = GetTarget();
if (attack != null && target != null)
{
attack.AttackTarget(GetTarget());
}
}

GameObject GetTarget()
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;

if (Physics.Raycast(ray, out hit))
{
return hit.collider.gameObject;
}

return null;
}
}

When posting code in the forum, make sure you use Code Tags so people can read it easily. You can edit your code to do that to (strongly recommend you do that now).

Some questions:

  • Do your enemies also have Fighter components attached to them?
  • Is the Fighter component on the same object as the Collider?

I have it all fixed now, (probably should’ve mentioned that earlier.) But I have a different problem now with one of my other projects, I think may have to change the unity version that my project is on but I don’t know how to do that.

Never mind. figured it out.

Great! For future reference remember we cannot see your screen and we cannot read your mind.

You may wish to consider this guide to save you a lot of time as well as get you much-better answers:

How to report your problem productively in the Unity3D forums:

http://plbm.com/?p=220

This is the bare minimum of information to report:

  • what you want
  • what you tried
  • what you expected to happen
  • what actually happened, log output, variable values, and especially any errors you see
    - links to actual Unity3D documentation you used to cross-check your work (CRITICAL!!!)

The purpose of YOU providing links is to make our job easier, while simultaneously showing us that you actually put effort into the process. If you haven’t put effort into finding the documentation, why should we bother putting effort into replying?

If you post a code snippet, ALWAYS USE CODE TAGS:

How to use code tags: https://discussions.unity.com/t/481379

  • Do not TALK about code without posting it.
    - Do NOT post unformatted code.
  • Do NOT retype code. Use copy/paste properly using code tags.
  • Do NOT post screenshots of code.
  • Do NOT post photographs of code.
  • Do NOT attach entire scripts to your post.
  • ONLY post the relevant code, and then refer to it in your discussion.

Got it.