Please could someone helpme change the scale of an object with transform.localscale? ,transform.localscale not working

I am creating a script to slide and on of the things I’m trying to do is to shrink the player when I press ctrl. I have made a reference to the player and dragged the object in but nothing happens when I press ctrl.
BTW, I am a total beginner :D.

Here’s the code I wrote:

void slide()
{
    if(Input.GetKey(KeyCode.LeftControl))
    {
        player.transform.localScale = new Vector3(0.5f, 1f, 0.5f);
    }
}

Hi,
Currently you are checking for input in function called slide but is this function even get called somewhere? Either change function name from slide to Update then it will be checking for input in a loop or place slide in an Update function:

void Update()
{
    slide();
}

void slide()
{
     if(Input.GetKey(KeyCode.LeftControl))
     {
          player.transform.localScale = new Vector3(0.5f, 1f, 0.5f);
     }
}

Update is a special function name for Unity, it is executing its content once per frame.