Issue with moving character along his/her local z axis when space key is pressed. (Parkour)

Hello guys, I am still fairly new to this but I need a question answered because it is really bugging me and stumping me on why it is not working.

I have done extensive research on this subject and no one that I had found has had the same problem.
I am trying to transform the local position of my character forward along its Z axis upon pressing the space key. My problem is very abnormal, because when I press the space key, it registers going one way, but when I go the opposite direction, it pushes my character BACKWARDS along the world z axis.

To better explain it I will give you an example of whats happening.
eg.
Character runs toward an object and plays a parkour animation over said object successfully. I turn around and run at the same object the opposite direction and instead of placing my character on the other side of the object after my animation is complete, it transforms my characters position backwards along its z axis.

The code i’m using:

if(Physics.Raycast(TriggerTop.transform.position, TriggerTop.transform.forward, topRay, 1)&&Input.GetKey(KeyCode.Space))
{
	Parkour_2();
}
else if(Physics.Raycast(TriggerBottom.transform.position, TriggerBottom.transform.forward, bottomRay, 1)&&Input.GetKey(KeyCode.Space))
	Parkour_1();
}

function Parkour_1()
{
Body.animation.CrossFade("Vault");
yield WaitForSeconds(0.5);
transform.localPosition.z=transform.localPosition.z+0.1;
Body.animation.CrossFade("Idle");

}

function Parkour_2()
{
Body.animation.CrossFade("Climb");
yield WaitForSeconds(2);
transform.localPosition.y=transform.localPosition.y+0.5;
transform.localPosition.z=transform.localPosition.z+0.2;
Body.animation.CrossFade("Idle");

}

Thank you for looking at my question! if anyone can help me fix my problem, it’d be Greatly appretiated!

Sincerely,
Bakos

Even though you are using localPosition, you are still increasing its value, which means moving it forward along the global Z axis. However, you probably set up the game so that the runner runs along the opposite of the world’s Z-axis. Try transform.localPosition.z=transform.localPosition.z-0.2;
If you want to make it so that it corresponds to where the character is facing, just have a Vector3.Dot check between the character’s forward and the global Z axis, and determine whether you want to add or subtract from the value depending on its results.