Can someone explain to me why this doesn't work and fix it, I want the script to turn a box green and set objective to true when the player presses 'e'. Right now when I use the script nothing happens.
var player : GameObject;
var range : float=10f;
var distance = Vector3.Distance(transform.position, player.transform.position);
var objective = false;
function PickUp()
{
if (Input.GetKeyDown("e"))
{
renderer.material.color = Color.green;
var objective = true;
print(objective);
}
}