Problem when i want to get points

Hi I need help whit my game. I want to make an object and when i collide whit it i going to get a point and it going to stand on a GUI text that i have 1 point but i cant make it work.


  1. Create the score object, set it's collider to trigger
  2. Create a new JavaScript and use the below code;
var scoreValue : int;
var scoreScript : ScoreManager;

function OnTriggerEnter(col : Collider){
  if(col.tag == "Player"){

  1. Add the above javascript to your score object. Create a new Javascript, name it ScoreManager, use the below code and add it to the object which has the GUIText component.
var score : int = 0;
var guiText : GUIText;

function AddScore(val : int){
  score += val;
  guiText.text = score.ToString();

  1. Make sure that your player's tag is set to Player and you assigned all the required variables in the inspector.

I haven't tested this so let me know if you encounter any errors. Hope this helps.

Hi thx for answer me but its not working =( what can i do?