Any idea how to do this? And is there a way to do the opposite… when the player isn’t pressing a key, an object turns invisible?
You can just set the “enabled” property of the renderer to true to make it visible and false to make it invisible:
someGameObject.renderer.enabled = false; //Turn it off
To use with a key:
someGameObject.renderer.enabled = Input.GetKey("k");