how to get this to work?

i have a platform with a box collider and rigid body, and this script attached to it:

v

ar customPlayAgainButton : GUIStyle;
var customQuitButton : GUIStyle;
var customBox : GUIStyle;
var triggerEnd : boolean;


function OnCollisionEnter(Collision : Collision) {
triggerEnd = true;

Debug.Log(Collision.gameObject.name+" collision entered");
}

if (triggerEnd == true) {


GUI.Box (Rect (450, 150, 350, 350),"", customBox);

if (GUI.Button (Rect (530, 230, 200, 90), "", customPlayAgainButton)) {

triggerEnd = false;
	
Time.timeScale = 1.0;

Application.LoadLevel (1);
scoreScript.score = 0;
scoreScript.text = scoreScript.score.ToString();


}

if (GUI.Button (Rect (530, 330, 200, 90), "", customQuitButton)) {
Application.LoadLevel (0);
scoreScript.score = 0;

}
}

i want it to, when the player collides with the object, the GUI elements pop up. Could anyone please tell me what im doing wrong? It does trace out, so i know the collision is succesfull

Try this

var customPlayAgainButton : GUIStyle;
var customQuitButton : GUIStyle;
var customBox : GUIStyle;
var triggerEnd : boolean;

function OnCollisionEnter(Collision : Collision) {
triggerEnd = true;
Debug.Log(Collision.gameObject.name+" collision entered");
}
function OnGUI () {
if (triggerEnd == true) {
GUI.Box (Rect (450, 150, 350, 350),“”, customBox);
if (GUI.Button (Rect (530, 230, 200, 90), “”, customPlayAgainButton)) {
triggerEnd = false;
Time.timeScale = 1.0;
Application.LoadLevel (1);
scoreScript.score = 0;
scoreScript.text = scoreScript.score.ToString();
}
if (GUI.Button (Rect (530, 330, 200, 90), “”, customQuitButton)) {
Application.LoadLevel (0);
scoreScript.score = 0;
}
}
}

Your GUI button etc needs to be in an:

function OnGUI() {

}

strangely it dont work. I actually got an almost identical script another place that works, only thing is its a trigger instead of collider. Could there be something very simple im forgetting here? If anyone can think of anything? Cause i have colliders working on other objects. This one traces out, and no errors. There just isnt any GUI popping up on collision. Cant figure it out, for me it seems im doing the exact same thing i have done before…

i just notice that the script seem to work sort of, cause i just pressed randomly on the screen and apparently hit the gui by accident.
The gui dont appear on screen, but when i press where the button is suppose to be, it direct me to where its suppose to be. Anybody come across a problem like this before?

i found out, my mistake :stuck_out_tongue:
Thanks for replies:)