Points system for unity

Hello, I am looking for advice for a points system. I have tried a couple things but they aren’t working very well at all. First of all I am trying to create a planet system, when you hit a planet an audio clip and an animation plays. I have tried with two different scripts. Here are those scripts.

    var PlayerScore : int;
     var ScoreText = "Score: 0";
     var MaxPoints : int;
     
     function OnTriggerEnter(other : Collider){
         if(other.tag == "Point"){
             PlayerScore += 1;
             ScoreText = "Score: " + PlayerScore;
             Destroy(other.gameObject);
         }
     }
     
     function Update(){
         if(PlayerScore > MaxPoints){
             PlayerScore = 0;
             print("MaxReached");
             ScoreText = "Score: 0";
         }
         GUI.Button(Rect(0,0,10,10),"Start");
     }

this did not work. In this script my goal was that after the player got to 10 points while receiving 1 point each time they hit a planet a start button would appear. A score counter was supposed to appear in the corner of the screen. The script didn’t do anything when I attached it to the planets, do I need to attach it to the player? If not if someone could help me with this that would be great. Thanks!

NoseKill is right. i gave him a thumbs up. you have to use buttons in a separate function. make sure your planets have colliders and your player has collider and rigidbody cpmponents. assuming everything else in you script is working the adjustment would look like this :

      var PlayerScore : int;
      var ScoreText = "Score: 0";
      var MaxPoints : int;
      var gobutton=false;
      function OnTriggerEnter(other : Collider){
          if(other.tag == "Point"){
              PlayerScore += 1;
              ScoreText = "Score: " + PlayerScore;
              Destroy(other.gameObject);
          }
      }
      
      function Update(){
          if(PlayerScore > MaxPoints){
              gobuttons=true;
              PlayerScore = 0;
              print("MaxReached");
              ScoreText = "i got"+PlayerScore;
          }}

function OnGUI () {

if(gobuttons){
          if(GUI.Button(Rect(0,0,10,10),"Start")){PlayerScore=0;gobutton=false;}
   GUI.Label(Rect(Screen.width*0.5,Screen.height*0.5,20,20),ScoreText);}}

Sorry i didnt test it. let me know if it works now.

GUI functions/commands are required to be in a void OnGUI(){ } function.
This looks like your problem. This is an addition to toddisarockstar’s answer.