GUI Label wont dislpay on my screen to show score

Hi guys i was wondering if someone has come accross this or can help.

I have created a GUI Label in my code so that it displays the score as a label in my game, but for some reason it does not show up in my game. Can some one tell me what i am doing wrong or what i should be doing as i have created the function for GUI label but its not working. I have put this in my shooter class this script is attached to my main camera which acts as th player :slight_smile:

using UnityEngine;
using System.Collections;

public class shooter : MonoBehaviour 
{
	public Rigidbody projectile; // prefab on it 
	public Transform shotPos;    // empty gameobject where to shoot from 
	public float shotForce = 1000f; //force of the projectile 
	public float moveSpeed = 10f;   // speed of camera
	public float forwardSpeed = 0.0f;  // forward speed
	public float backwardSpeed = 0.0f;  // backward speed
	public static int Score = 0;
	public static int Lives = 3;
	
	// Update is called once per frame
	void Update () 
	{
		// x axis
		float h = Input.GetAxis("Horizontal") * Time.deltaTime * moveSpeed;
		transform.Translate(new Vector3(h,0,0));
		
		if(Input.GetKey(KeyCode.F))
		{
		transform.Translate(new Vector3(0,0,forwardSpeed)* Time.deltaTime);
		}
		if(Input.GetKey(KeyCode.B))
		{
			transform.Translate(new Vector3(0,0,-backwardSpeed)* Time.deltaTime);
		}
		
		
		if(Input.GetButtonUp("Fire1"))
		{
			Rigidbody shot = Instantiate(projectile, shotPos.position, shotPos.rotation)as Rigidbody;
			shot.AddForce(shotPos.forward * shotForce);
		}
		
		
	
		// Display the score on the screen as a label
	}	
		void OnGui()  // called every frame
		{
		GUI.Label(new Rect(20,10,100,100), "Score: " + shooter.Score.ToString());
		}
	
	
}

I’m fairly sure you just need

 GUI.Label(new Rect(20,10,100,100), "Score: " + Score);

edit: and as a nitpick, classes really should have capital first letters. Helps differentiate types from variables (assuming variables are all lower case first letters which you’ve also mixed a little in the example…)

Yeah sorry about that agreed. I tried that LeftyRighty but i still cannot see it i dont understand and i am getting no errors either could i do this with gui.text

ah

OnGUI()
not
OnGui()

Top man i feel like a right thicko now, thanks buddy i appreciate it :slight_smile: