So I’ve coded my very first thing ever in JS and it doesn’t seem to work? Kinda new to JS scripting but this script right here goes on the Player.
#pragma strict
var currentDeaths : int = 0;
function OnGUI()
{
GUI.Box(Rect(5, 180, 50, 20), "Deaths");
GUI.Box(Rect(54, 180, 40, 20), "" + currentDeaths);
}
This code goes on the block/gameObject that’ll kill him but it seems to not work?
#pragma strict
private var material : DeathScript;
function Start()
{
material = GameObject.Find("First Person Controller").GetComponent(DeathScript);
}
function OnTriggerEnter(Col : Collider)
{
if(Col.tag == "Player")
{
Destroy(gameObject);
material.currentDeaths++;
Application.LoadLevel("Scene2");
}
}