i use this script to kill my enemies on the game:
function OnTriggerEnter(hit : Collider)
{
if(hit.gameObject.tag==“Ray”){
Destroy(gameObject); }}
how can i make a GUI box that will add +1 whenever i kill the enemy?
i have gotten some scripts but never made them work 
any aswers would be really appreciated!! -Goatria
You can’t have your Gui code in the same script as this, as when you destroy the gameobject the stuff you’ve added to the Gui will disappear.
You can make a static variable somewhere, say in your player script, or another script that holds your game info:
static var score : int = 0;
You will then be able to call on that variable from anywhere else. Increment your score using:
(Whatever script your score variable is in).score += 1;
Then either in your player script, or a seperate script for GUI, create a label and add your score to it:
function OnGUI(){
GUI.Label(Rect(10, 10, 50, 100), "Score: " + (Whatever script your score variable is in).score);
}
THANKS!!! MADE IT WORK!!! XDD haha
what i did:
added this to my character’s momevemt score:
static var score : int = 0;
then i made a script called “GUI Score”, this is the script:
function OnTriggerEnter(hit : Collider)
{
if(hit.gameObject.tag==“Enemy”){
Destroy(gameObject); }
Movement.score += 1;
}
and finally made another script and named it “GUI Score2”:
function OnGUI(){
GUI.Label(Rect(10, 10, 50, 100), "Score: " + Movement.score);
}
and now whenever i kill the enemy i get 1 point!!! AWESOMEEEEE!!! thank u so much Mike!!
A good way to manage score, health, lives, ect is to create a GameManager object and have a script called GameManager on it that way you know if you want to query something, you just type GameManager.score or GameManager.lives You can also keep this throughout levels by telling it not to destroy it on level load.