Hey people I’m new to java script so kind of stuck on this one. I have a door that will have a keycode panel on it and when the player gets to the door he will enter the 4 number code then the door will animate open. so far i have the GUI code panel on screen but when the code is entered nothing happens. I want the codedooranimation clip to play.
var secretCode = new Array(1,3,3,7);
var playerEntry = new Array();
function OnGUI () {
GUI.Box (Rect (10,10,300,110), "Enter the security code");
if(GUI.Button(Rect (110,30,25,20), "1")){ playerEntry.Push(1); }
else
if(GUI.Button(Rect (135,30,25,20), "2")){ playerEntry.Push(2); }
else
if(GUI.Button(Rect (160,30,25,20), "3")){ playerEntry.Push(3); }
else
if(GUI.Button(Rect (110,50,25,20), "4")){ playerEntry.Push(4); }
else
if(GUI.Button(Rect (135,50,25,20), "5")){ playerEntry.Push(5); }
else
if(GUI.Button(Rect (160,50,25,20), "6")){ playerEntry.Push(6); }
else
if(GUI.Button(Rect (110,70,25,20), "7")){ playerEntry.Push(7); }
else
if(GUI.Button(Rect (135,70,25,20), "8")){ playerEntry.Push(8); }
else
if(GUI.Button(Rect (160,70,25,20), "9")){ playerEntry.Push(9); }
else
if(GUI.Button(Rect (135,90,25,20), "0")){ playerEntry.Push(0); }
if(playerEntry==secretCode){ print("Entered the correct code!");
animation.Play ("codedooropen");
}
else{ playerEntry = new Array(); print("Entered the wrong code!"); }
}