OnEpisodeBegins Rotation problem

I’m trying to figure out how to reset each episode correctly.
I’m making a very simple racing game and currently I’m trying to train the AI.
After the AI crashes I want it to return to the start position.
The positioning works well and it returns to where its supposed to be but the rotation doesn’t.
Atleast it doesnt stay in the correct rotation.
For at most a frame the rotation is correct and the it snaps back to where it was as it crashed.
This is how it behaves during a crash, manually played

And this is the code for OnEpisodeBegin() and OnActionsRecieved()

public override void OnEpisodeBegin()
    {
        Carcontroler.SetinputVector(new Vector2(0, 0));
        Target = GameObject.Find("Grid 1").transform.GetChild(3).GetChild(0);
        targetPosition = Target.GetComponent<Checkpoint>().GetWorldPositionOfCheckpoint(Target);
        //rb2d.angularVelocity = 0f;
        //rb2d.velocity = Vector2.zero;
        transform.localPosition = new Vector2(44.45f, 198.12f);
        rb2d.SetRotation(0);
        //transform.Rotate(transform.eulerAngles);
        //transform.eulerAngles = new Vector3(0,0,0);
        //rb2d.rotation = 0;
        timeSinceLapStarted = Time.time;
    }
public override void OnActionReceived(ActionBuffers actionBuffers)
    {
        // Actions, size = 2
        Vector2 controlSignal = Vector2.zero;
        controlSignal.x = actionBuffers.ContinuousActions[0];
        controlSignal.y = actionBuffers.ContinuousActions[1];
        Carcontroler.SetinputVector(controlSignal);

        // Rewards
        // When car drives into next checkpoint
        if (reachedNextCheckpoint)
        {
            SetReward(nextCheckpointReward);
            reachedNextCheckpoint = false;
        }
        //// Punish AI
        //// When car crashes
        if (crashed)
        {
            //SetReward(crashPunish);
            crashed = false;
            EndEpisode();
        }
    }

The car steering is from a separate script handling the physics.

I’ve tried a lot of different stuff but nothing seems to work.

Finally fixed it. Needed to clear actionbuffer and make a new function in the carcontroller.