Gameobject and camera detection

So, I created this Javascript script for if a camera detects this certain gameobject, it load the level ‘goodnight’.

#pragma strict

function Start () {
	if (renderer.isVisible) {
   Application.LoadLevel("goodnight");
}
}

function Update () {
	if (renderer.isVisible) {
   Application.LoadLevel("goodnight");
}
}

Now, it always keeps loading the level regardless, and cast and recieve shadows have been turned off and it still does not work. What should be changed in the code?

Read this quote from the scripting reference site:

“Note that object is considered visible when it needs to be rendered in the scene. It might not be actually visible by any camera, but still need to be rendered for shadows for example. Also, when running in the editor, the scene view cameras will also cause this value to be true”

So using isVisible isnt enough, you need to work out that the camera in game has actually seen the gameobject, probably using raycasts is a good idea.