Need help whats wrong?

I’ve just start a course learning about coding and this is my first project. if you got any tips or you know whats wrong please teach me your wisdom.
ps. its a pong basic game

Racket code

var key_up : KeyCode;
var key_down : KeyCode;
static var player1:int = 0;
static var player2:int = 0;

function Start () {

}

function FixedUpdate () {

   // get current position
   var pos : Vector3 = transform.position;
  
   if (Input.GetKey(key_up)) {
      // player wants to move the racket upwards
      transform.position = new Vector3(pos.x, pos.y, pos.z + 0.05);
   }
   else
   {
       if (Input.GetKey(key_down)) {
           // player wants to move the racket downwards
           transform.position = new Vector3(pos.x, pos.y, pos.z - 0.05);
           
   if (transform.position.z > -8.13)
    {  transform.position.z = -8.13;
   }
   else
   if (transform.position.z > -9.54)
    {  transform.position.z = -9.54;
    }    
       }// end if down key
          
   }// end if up key
   
}// end function FixedUpdate

Ball code

function Start () {

  //Make the Ball move diagonally right
  //ToDo: Make the Ball do in a random direction to start
  rigidbody.velocity.z = 1;
  rigidbody.velocity.x =1;
  
}

function Update () {
  //Make the ball keep its initial speed
  rigidbody.velocity = rigidbody.velocity.normalized;
}

function OnCollisionEnter (collision:Collision){
  // Do Things when the ball collides wirth something
      //add scores   
    if (Collision.name "BorderRight");
     {
      Player1++;
     Transform.position.x = 0;
     Transform.position.z = 0;
     }
    else
    if (Collision.name "BorderLeft");
    {
      Player2++;
     Transform.position.x = 0;
     Transform.position.z = 0;
    } 
      if (collision.collider.name == "WallLeft");
      {
       //ToDo: right player scores a point
       //ToD: restart ball at centre with random direction
       
       //ToDo: Remove Temporary: make ball bounce off the wall
       rigidbody.velocity.x = -1.0 * rigidbody.velocity.x;
     }
     else if (collision.collider.name == "WallRight");
     {
       //ToDo: left player scores a point
       //ToDo: restart ball at centre with random direction
       
       //ToDo: Remove Temporary: make ball bounce off the wall
       rigidbody.velocity.x = -1.0 * rigidbody.velocity.x;
     }
     else if (collision.collider.name == "WallTop");
     {
       //ToDO bounceoff in the way we want it to
       rigidbody.velocity.z = -1.0 * rigidbody.velocity.z;
     }
     else if (collision.collider.name == "WallBottom");
     {
       //ToDO bounceoff in the way we want it to
       rigidbody.velocity.z = -1.0 * rigidbody.velocity.z;
     }
     else if (collision.collider.name == "PaddleLeft");
     {
       //ToDO bounceoff in the way we want it to
       rigidbody.velocity.x = -1.0 * rigidbody.velocity.x;
     }
     else if (collision.collider.name == "PaddleRight");
     {
       //ToDO bounceoff in the way we want it to
       rigidbody.velocity.x = -1.0 * rigidbody.velocity.x;
     }
  rigidbody.velocity = -1.0 * rigidbody.velocity;
  
  }

Guitext(players score)

var Player1 : GUIText;
var Player2 : GUIText;

function Start () {

}

function Update () {

function (on GUI());
{
 player1.text = "Player1" + Ball.Player1;
 player2.text = "Player2" + Ball.Player2;
}

Thank you for taking your time to help a newbie :slight_smile:

whoa OK it looks like a lot of code errors here. I highly recommend practicing some more coding, your if statements have incorrect syntax on almost all of them. Have a look below at the Ball code to see that there are no semicolons at the end of an If statement and some of the conditions dont have any logical operators (== <= >= etc):

function Start () {
 
  //Make the Ball move diagonally right
  //ToDo: Make the Ball do in a random direction to start
  rigidbody.velocity.z = 1;
  rigidbody.velocity.x =1;
 
}
 
function Update () {
  //Make the ball keep its initial speed
  rigidbody.velocity = rigidbody.velocity.normalized;
}
 
function OnCollisionEnter (collision:Collision){
  // Do Things when the ball collides wirth something
      //add scores   
    if (Collision.name == "BorderRight")
     {
      Player1++;
     Transform.position.x = 0;
     Transform.position.z = 0;
     }
    else
    if (Collision.name == "BorderLeft")
    {
      Player2++;
     Transform.position.x = 0;
     Transform.position.z = 0;
    } 
      if (collision.collider.name == "WallLeft")
      {
       //ToDo: right player scores a point
       //ToD: restart ball at centre with random direction
 
       //ToDo: Remove Temporary: make ball bounce off the wall
       rigidbody.velocity.x = -1.0 * rigidbody.velocity.x;
     }
     else if (collision.collider.name == "WallRight")
     {
       //ToDo: left player scores a point
       //ToDo: restart ball at centre with random direction
 
       //ToDo: Remove Temporary: make ball bounce off the wall
       rigidbody.velocity.x = -1.0 * rigidbody.velocity.x;
     }
     else if (collision.collider.name == "WallTop")
     {
       //ToDO bounceoff in the way we want it to
       rigidbody.velocity.z = -1.0 * rigidbody.velocity.z;
     }
     else if (collision.collider.name == "WallBottom")
     {
       //ToDO bounceoff in the way we want it to
       rigidbody.velocity.z = -1.0 * rigidbody.velocity.z;
     }
     else if (collision.collider.name == "PaddleLeft")
     {
       //ToDO bounceoff in the way we want it to
       rigidbody.velocity.x = -1.0 * rigidbody.velocity.x;
     }
     else if (collision.collider.name == "PaddleRight")
     {
       //ToDO bounceoff in the way we want it to
       rigidbody.velocity.x = -1.0 * rigidbody.velocity.x;
     }
  rigidbody.velocity = -1.0 * rigidbody.velocity;
 
  }

So I’ll hit the errors in order.

The first error, says that it’s a problem with Ball.js, line 20 and it doesn’t understnad what to do with “Border Right”. If you look at that line, you’ll see if (Collision.name "BorderRight"); which indeed, is incorrect because you need to use == :

 if (Collision.name == "BorderRight");

However, that’s not quite right either, because the collision doesn’t have a name. Perhaps you mean the gameobject you collided with, so

if(Collision.gameObject.name == "BorderRight");

So fix those things in that script.

The second error is probably related to that as well. So the third error, says in GUITeaxt.js line 13 has an unexpected token. Looking at that function, your onGUI function has a few problems…too many parenthesis and an extra semicolon, it should start like this

function OnGUI () {

That might take care of most of the errors, but odds are, once you fix those you’ll find more.