My script is for respawning the player and show a gui to click enter to respawns ,but when the player dies he respawns without needing to press enter and there is no gui showing. if(playerisDead){ Respawn.SetActive(true); if (!audioPlayed) { GetComponent<AudioSource>().clip = MarioSound ; GetComponent<AudioSource>().pitch = Random.Range(0.85f, 1.1f); GetComponent<AudioSource>().Play(); audioPlayed = true; } if(Input.GetKeyDown(KeyCode.Return)); { RespawnPlayer(); } } } void OnGUI() { } void RespawnPlayer() { Respawn.SetActive(false); Vector3 newPos = new Vector3(Random.Range(Xmin,Xmax),Random.Range (Ymin,Ymax),Random.Range(Zmin,Zmax)); Object PlayerRagdoll = Instantiate(PlayerDead,transform.position,Quaternion.identity)as GameObject; transform.position = newPos; playerisDead = false;
Copy/paste your code in here with code tags. It's hard to tell what the problem is from a screenshot of some of the code.
there is a sticky on code tags at the top of the scripting forum, they really help make code readable on the forums
looks like you have included the old legacy OnGUI function... but haven't told it to do anything, so it's not going to show anything. You're probably better off looking at the tutorials on the new UI system in unity from 4.6+ http://unity3d.com/learn/tutorials/modules/beginner/ui also what is "Respawn" on line 18 and 25 referring to? neither the screen shot or the code you pasted includes the declaration of that variable. Does that have a script attached to it?
i am not using the OnGUI function that was something i just forgot to delete. The gui is shown with a empty game object with two gui textures attached being turned off and on.