Change shape of object if selected?

What I am trying to achieve here is to be able to change the shape and size of an object but only if the object has been selected. My script makes sense to me but does not work. The object can be selected but when I use any of the WASD keys to change its shape nothing happens. Can someone help me out?

    var selected = false;
    var SelectedGameObject : GameObject;
    
    
    function Update (){
    
    if(Input.GetMouseButtonDown(0)){
    
    var hit : RaycastHit;
    var ray : Ray = Camera.main.ScreenPointToRay (Input.mousePosition);
    
    if (Physics.Raycast (ray, hit, 100.0)){
    SelectedGameObject = hit.collider.gameObject;
    
    selected = true;
    Change();
    Wait(hit.collider.renderer);
    }
    }
    }
    
    function Change (){
    
    if(Input.GetKeyDown(KeyCode.A)){
    transform.localScale += Vector3(0.1,0,0);
    }

    if(Input.GetKeyDown(KeyCode.D)){
    transform.localScale += Vector3(-0.1,0,0);
    }

    if(Input.GetKeyDown(KeyCode.W)){
    transform.localScale += Vector3(0,0,0.1);
    }

    if(Input.GetKeyDown(KeyCode.S)){
    transform.localScale += Vector3(0,0,-0.1);
    }
    }
    
    function Wait(rend : Renderer){
    
    var originalColor = rend.material.color;
    rend.material.color = Color.yellow;
    yield WaitForSeconds(2);
    rend.material.color = originalColor;
    }

The problem is that your Change function is inside an Input.GetMouseButtonDown() condition.
The only possible way to change the scale of your object if you manage to click and push the button in the same frame. So nearly impossible. What i suggest is something like this:

function Update (){
 
    if(Input.GetMouseButtonDown(0)){
 
    var hit : RaycastHit;
    var ray : Ray = Camera.main.ScreenPointToRay (Input.mousePosition);
 
    if (Physics.Raycast (ray, hit, 100.0)){
    SelectedGameObject = hit.collider.gameObject;
 
    selected = true;
    Wait(hit.collider.renderer);
    }
    }


    if(selected)
    {
       Change();
    }
 }