how to make a combo system

hi i would like to know how to make a combo system where you press the z button the first time it it does one attack i press it a second time it does another and another when press a third and fourth time in secession sincerely Zaygon35

This is what I have use for combo attack. I had it from wiki. I think it’s what you want…

using UnityEngine;
public class KeyCombo{
    public string[] buttons;
    private int currentIndex = 0; //moves along the array as buttons are pressed
 
    public float allowedTimeBetweenButtons = 0.7f; //tweak as needed
    private float timeLastButtonPressed;
 
    public KeyCombo(string[] b)
    {
        buttons = b;
    }
 
    //usage: call this once a frame. when the combo has been completed, it will return true
    public bool Check()
    {
        if (Time.time > timeLastButtonPressed + allowedTimeBetweenButtons) currentIndex = 0;
        {
            if (currentIndex < buttons.Length)
            {
                if ((buttons[currentIndex] == "left" && Input.GetKeyDown(KeyCode.Z)) || (buttons[currentIndex] == "right" && Input.GetKeyDown(KeyCode.Z)))
                {
                    timeLastButtonPressed = Time.time;
                    currentIndex++;
                }
 
                if (currentIndex >= buttons.Length)
                {
                    currentIndex = 0;
                    return true;
                }
                else return false;
            }
        }
 
        return false;
    }
}


public class ApplyCombo : MonoBehaviour {
    private KeyCombo combo1 new KeyCombo(new string[] {left,right,right});
    private KeyCombo combo2 new KeyCombo(new string[] {left,right,left});
    private KeyCombo combo3 new KeyCombo(new string[] {right,right,left});
 
    void Update () {
        if (combo1.Check()){
            // your script here
            // do the falcon punch
            Debug.Log("PUNCH"); 
        }

        if (combo2.Check()){
            // your script here
            // do the falcon punch
            Debug.Log("KICK"; 
        }

        if (combo3.Check()){
            // your script here
            Debug.Log("Combo3");
        }
    }
}