Toggle button help

hi can anyone make a scipt that does so i can press a button on my keyboard to toggle a objects visibility example: i press Ctrl and a object (no matter where i am) will get removed if i then press Ctrl again it will come back or if i press Shift it will then come back

use `Input.GetButtonDown` since it returns `true` only on the frame the button is pressed, not every frame while the button is pressed.

if (Input.GetButtonDown("Fire1")) {
    // Toggle code here
}

To make something invisible you can deactivate the gameObject

gameObject.active = false;

in a script `gameObject` refers to the game object that the script is attached to, which you don't want to do because it will stop scripts form executing on that game object and then you will only be able to toggle to `false` and then the script wont run. If you want to work with another game object you need to add a variable of type `GameObject` to the top of the script (outside all functions) like

var myGameObject : GameObject;

Then you'll need to link that property to the target game object in the inspector.

and a one liner for toggling `true`/`false` states:

myGameObject.active = !myGameObject.active;