[SOLVED] Script OnTrigger for load scene

Hello…i have problem with my work…
i have script code for load scene if collide a cube, such as :

var levelToLoad : String;
 
function OnTriggerEnter(hit : Collider)
{
Application.LoadLevel(levelToLoad);

but , when i play my scene…system load level without my player hit a cube…

any solution, please??

The cube probably collide with some other thing like ground. You should do a check like

if (hit.gameObject.name == “PlayerName”)
Application.LoadLevel(levelToLoad);

Alternatively, you could use tags, or a special Player Layer and OnPlayer layer which would make the trigger only collide with players.