Changing The Value Of A Variable From Another Script (JavaScript)

I have my script called PlayerAnimations, and a script called ColliderTrigger1. Player animations is like this (javascript):

var parkour1 = false;

function Update ()
{
    if (parkour1 == true)
    {
         animation.Play("parkour1")
    }
}

and I want the script ColliderTrigger1 to do something like this:

//Get the parkour1 variable from script PlayerAnimations

function Update ()
{
	
	if (Input.GetKey(KeyCode.G))
	{
		//parkour1 = true;
	}
	
}

How would i do this. I want to access the variable from the script, then change it to true if player hits ‘G’. I just don’t understand how to get the variable from the script, then how to change it to true.

Hi! I am quite new to Unity myself, but I believe this is how you would achieve this. First, you must create a reference to the PlayerAnimations script from the ColliderTrigger1 script, like so:

var playerAnimationsScript: PlayerAnimations;

function Start () {
    playerAnimationsScript = GetComponent(PlayerAnimations);
    
}

Now, you can manipulate the parkour1 variable like so:

function Update () {
    if (playerAnimationsScript.parkour1 == "some value") {
         playerAnimationsScript.parkour1 = "some other value";
    }
}