Displaying Score on screen

I need a script that when I hit a game object my score increase by 2 and is displayed on the screen. I have been trying to make it work myself, but I haven’t made it work.

Thanks.

You didn’t post what you did have but something like

OnTrigger/Collider () {

playerScore += 2;
}

OnGUI {
GUI.Box(new Rect(10,10,100,30),playerScore.ToString());
}

Use ontriggerenter