How to make so that when I press a button it selects it?

How to make so that when I press a button it selects it?

Selects what?

public GameObject objectToSelect; // place game object you want to select in this field in inspector
bool select = false;

void Update(){

if (Input.GetKeyDown("space")){
if(select){
select = false;
}
if (!select){
select = true;
}
}
if(select){
objectToSelect.transform.Rotate(2, 0, 0); //rotate object to show it is selected
}
}