How To Make Game Remember User Input Then Play It Out, But Backwards

Ok so i made a game where once a person has made enough arrow key presses (still have to code that part) the should remember which keys were pressed and play them out when a certain condition is filled.
However the keys should be played backwards. Ex. If I press up arrow down arrow right arrow; the game should play right arrow, down arrow, up arrow.

this shows the behavior you describe

const int maxStepCount = 5;
Vector2 stepRecord = new Vector2[maxStepCount];
int stepCount;

    void AddStep(Vector2 dir)
    {
        stepRecord[stepCount++] = dir;
    }

    private void Update()
    {
        if (keyPressed)
            AddStep(inputDir);

        if(stepCount >= maxStepCount-1)
        {
            for (int i = stepRecord.Length - 1; i >= 0; i--)
                This is the sequence in reverse => stepRecord*;*

}
You can work from here. Hope it helps.

Hi I have got my rewind script working. Theres only one issue. In my rewind script I disable my movement script then re enable it after the rewind is done. My only issue is that after completing the rewind, my player character is able to move but for some reason not jump. Here is my movement script -

using UnityEngine;

public class Movement : MonoBehaviour
{
public float speed;
public float jumpForce;
private float moveInput;

private Rigidbody2D rb;

private bool facingRight = true;

private bool isGrounded;
public Transform groundCheck;
public float checkRadius;
public LayerMask WhatIsGround;

private int extraJumps;
public int extraJumpsValue;

void Start()
{
    extraJumps = extraJumpsValue;
    rb = GetComponent<Rigidbody2D>();
}

void FixedUpdate() // We did "FixedUpdate" because we are dealing wth physics
{
    isGrounded = Physics2D.OverlapCircle(groundCheck.position, checkRadius, WhatIsGround);

    moveInput = Input.GetAxis("Horizontal");
    Debug.Log(moveInput);
    rb.velocity = new Vector2(moveInput * speed, rb.velocity.y);

    if (facingRight == false && moveInput > 0)
    {
        Flip();
    }
    else if (facingRight == true && moveInput < 0)
    {
        Flip();
    }
}

void Update()
{
    if (isGrounded == true)
    {
        extraJumps = extraJumpsValue;
    }

    if (Input.GetKeyDown(KeyCode.UpArrow) && extraJumps > 0)
    {
        rb.velocity = Vector2.up * jumpForce;
        extraJumps--;
    }

 

    else if (Input.GetKeyDown(KeyCode.UpArrow) && extraJumps == 0 && isGrounded == true)
    {
        rb.velocity = Vector2.up * jumpForce;
    }

}

void Flip()
{
    facingRight = !facingRight;
    Vector3 Scaler = transform.localScale;
    Scaler.x *= -1;
    transform.localScale = Scaler;
}

}

AND HERE IS MY REWIND SCRIPT #1 -

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

public class CommandHandler : MonoBehaviour
{

public bool isRewinding = false;

List<PointInTime> pointsInTime;

Rigidbody2D rb;

//for Timer

private float secondsCount;
private int minuteCount;

// For s

// Start is called before the first frame update
void Start()
{
    pointsInTime = new List<PointInTime>();
    rb = GetComponent<Rigidbody2D>();

}

// Update is called once per frame
void Update()
{
    UpdateTimerUI();// for timer

    if (secondsCount > 10)
    {
        StartRewind();
        Debug.Log("10 second rewind begins");
        
    }

    if(secondsCount > 18)
    {
        StopRewind();
        Debug.Log("10 second rewind ended");
       
    }

    if (secondsCount > 30)
    {
        StartRewind();
        Debug.Log("30 second rewind begins");
       
    }

    if (secondsCount > 35)
    {
        StopRewind();
        Debug.Log("30 second rewind ended");
       
    }

    if (minuteCount > 1) 
    {
        StartRewind();
        Debug.Log("1 minute rewind begins");
        
    }

    if (minuteCount > 1.2) 
    {
       StopRewind();
        Debug.Log("1 minute rewind ends");
      
    }

And here is rewind script #2 -

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

public class PointInTime
{
public Vector3 position;
public Quaternion rotation;

public PointInTime (Vector3 _position, Quaternion _rotation)
{
    position = _position;
    rotation = _rotation;

}

}

Okay everyone I solved my problem, all I did was incorporated a timer and then at certain times started and ended the rewinds. Instead of disabling the movement, I figured out the rewind script was actually not allowing movement while playing, the only reason it looked like that, is because it would still allow the character to flip which way they were facing. To fix this I simply made a mother sprite(which btw looks the same even if it is mirrored) and just used it whenever I needed to rewind.