How can you compare the contents of two arrays?

Could anyone help with comparing whether one sequence is equal to a correct sequence of numbers. My code basically lets the player hit 7 notes on a xylophone and after the 7th one it checks the players input with the correct sequence but for some reason it runs both situations, saying it is correct even if the contents of one array do not match the contents of another. Any help would be greatly appreciated.

public class SCR_Xylophone : MonoBehaviour
{
    [SerializeField] private int[] correctSequence = { 1, 1, 5, 5, 6, 6, 5 };
    [SerializeField] private int[] playerSequence = { 0, 0, 0, 0, 0, 0, 0 };
    [SerializeField] private Animator anim;
    [SerializeField] private AudioSource incorrectSound;
    [SerializeField] private AudioSource successSound;
    private int index = 0;

    void Update()
    {
        //Checks to see whether the players input is the correct input & plays an animation if true
        if (index == 7)
        {
            for (int i = 0; i < correctSequence.Length; i++)
            {
                if (playerSequence _!= correctSequence*)*_

{
index = 0;
incorrectSound.Play();
}
else if(playerSequence == correctSequence*)*
{
StartCoroutine(SuccessSequence());
GetComponent<SCR_Xylophone>().enabled = false;
}
}
}
}
//Checks to see what bar has been hit and changes each element in the array & increases the index
public void AttemptSequence(int barValue)
{
switch(index)
{
case 0:
break;
case 1:
playerSequence[0] = barValue;
break;
case 2:
playerSequence[1] = barValue;
break;
case 3:
playerSequence[2] = barValue;
break;
case 4:
playerSequence[3] = barValue;
break;
case 5:
playerSequence[4] = barValue;
break;
case 6:
playerSequence[5] = barValue;
break;
case 7:
playerSequence[6] = barValue;
break;
}
}

IEnumerator SuccessSequence()
{
anim.SetBool(“isCorrect”, true);
successSound.Play();
yield return new WaitForSeconds(1f);
successSound.Stop();
}
}

I highly advise you the following rework.

Keep as many things private as possible. If anyone outside of your class can change the values anytime, you loose control over what’s going on. The other classes don’t need to know how your class works internally. Just add methods to your class your other classes will just need to call, and do the logic inside those methods.

public class SCR_Xylophone : MonoBehaviour
{
    // SerializeField allows you to keep the variable private while being able to edit it in the inspector
    [SerializeField] private int[] correctSequence = { 1, 1, 5, 5, 6, 6, 5 };
    [SerializeField] public Animator anim;
    [SerializeField] public AudioSource incorrectSound;
    [SerializeField] public AudioSource successSound;
    private int _playerInputIndex = 0;

    // Call this method outside of your class
    // instead of manipulating index and playerSequence 
    public void AddPlayerInput(int value)
    {
        // Reset if incorrect value provided
        if(value != correctSequence[_playerInputIndex])
        {
            _playerInputIndex = 0;
            incorrectSound.Play();
            return;
        }

        // Correct input
        _playerInputIndex++;

        // Last input reached, meaning all the values are correct
        if(_playerInputIndex == correctSequence.Length)
        {
            _playerInputIndex = 0;
            StartCoroutine(SuccessSequence());
            GetComponent<SCR_Xylophone>().enabled = false;
        }
    }