I'm very new to scripting and here is my question: what is wrong with my script? no errors, I want to press a key (f) in my trigger to load a new level (my trigger is next to a door)

function OnTriggerEnter(){

if(Input.GetKey ("f"))
{
	Application.LoadLevel("firsthouse");
}

}

Hello,

I don’t know what you trying to achieve but as fas as I know there are two possibility you wanna achieve

  1. When you will press “F” Buttons the scene should load.

    void Update(){
    if (Input.GetKeyDown (KeyCode.F)) {
    Application.LoadLevel(“SceneNameHere”);
    }
    }

    void OnTiggerEnter(){
    // Do What you wanna do here :slight_smile:
    }

  2. Now If you don’t want the above thing but you need that when the OnTriggerEnter() should call then load the scene

    void OnTiggerEnter(){
    Application.LoadLevel(“SceneNameHere”);
    }

*Note:- The only mistake in your code is, It will only execute only just when OnTriggerEnter() is called and the same time you press “F” button.

I’m also assuming that you want to do like, there is a region present in the scene and if the player is in that region & if s/he press the “F” button then the scene should load. If that is the case then you have to do the following :-

  void OnTriggerStay(Collider coll){
		if ( coll.transform.tag == "Player" && Input.GetKeyDown(KeyCode.F)){
			Application.LoadLevel("SceneNameHere");
		}
	}

This is in C# but
Don’t forget to go in to file, Build Settings… And add your levels

    void Update () {
    if(Input.GetKey(KeyCode.F))
    {
    Application.LoadLevel("firsthouse");
    }
    }