Auto attack not working

so its suppose to when i press x wait 4 seconds and trigger a message that waiting has occured in the debug log than repeat the auto attack function at this point for some reason the ienumrator is not kicking in at all

using UnityEngine;
using UnityEngine;
using System.Collections;
using System;

public class Player1 : Creature
{
  bool combatstate;
  public int waittime;
  public static Player1 player;

  public static bool isAttacking;

  public static Transform opponent;
  public Animator attackanimaton;

  // Use this for initialization
  void Awake()
  {
  player = this;
  isAttacking = false;
  combatstate = false;

  }

  // Update is called once per frame
  void Update()
  {
  Attack();
  attackanimaton = GetComponent<Animator>();
  isAttacking = false;
  attacksuccess();
  }

  IEnumerator AutoAction()
  {
  Debug.Log("waiting");
  attackanimaton.SetFloat("Attack", 4.0f);
  yield return new WaitForSeconds(4);
  Debug.Log("waiting");
  Attack();
  }

  void attacksuccess()
  {
  if (Input.GetKey(KeyCode.X))
  {
  Debug.Log("combatstate is D");
  combatstate = !combatstate;
  }
  }


  protected override void Attack()
  {

  if (combatstate == true)
  {

  if (opponent != null && Vector3.Distance(opponent.position, transform.position) < range)
  {
  Debug.Log("is attacking");
  attackanimaton.SetBool("isAttacking", true);
  attackanimaton.SetFloat("Attack", 9.0f);
  opponent.GetComponent<Enemy>().GetHit(damage);
  AutoAction();
  }





  }

  }
  }

Shouldn’t you use: StartCoroutine(AutoAction())?

sorry a bit of a noob here were exactly would i place that?

Change your script to this:

using UnityEngine;
using UnityEngine;
using System.Collections;
using System;
public class Player1 : Creature
{
  bool combatstate;
  public int waittime;
  public static Player1 player;
  public static bool isAttacking;
  public static Transform opponent;
  public Animator attackanimaton;
  // Use this for initialization
  void Awake()
  {
  player = this;
  isAttacking = false;
  combatstate = false;
  }
  // Update is called once per frame
  void Update()
  {
  Attack();
  attackanimaton = GetComponent<Animator>();
  isAttacking = false;
  attacksuccess();
  }
  IEnumerator AutoAction()
  {
  Debug.Log("waiting");
  attackanimaton.SetFloat("Attack", 4.0f);
  yield return new WaitForSeconds(4);
  Debug.Log("waiting");
  Attack();
  }
  void attacksuccess()
  {
  if (Input.GetKey(KeyCode.X))
  {
  Debug.Log("combatstate is D");
  combatstate = !combatstate;
  }
  }
  protected override void Attack()
  {
  if (combatstate == true)
  {
  if (opponent != null && Vector3.Distance(opponent.position, transform.position) < range)
  {
  Debug.Log("is attacking");
  attackanimaton.SetBool("isAttacking", true);
  attackanimaton.SetFloat("Attack", 9.0f);
  opponent.GetComponent<Enemy>().GetHit(damage);
 StartCoroutine(AutoAction())
  }
  }
  }
  }