making my gun shoot...

My problem with my gun so far is the bullet. I know i need it to go out a distance and then go back to the gun, but doing that, is over my head. here is the code i saw and put on my bullet: using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class bulletscript : MonoBehaviour {

var Bullet : Transform;
var Spawn : Transform;

function Update ()
{
	if(Input.GetButtonDown("Fire1"))
	{
		Shoot();
	}
}

function Shot()
{
	var pel = Instantiate(Bullet, Spawn.position, Spawn.rotation);
	pel.rigidbody.AddForce(transform.forward * 8000);

}}

so the error it gives it the :'s in the beginning of the code, and I tried using ='s but I have no idea what i am doing. anyway, thanks!

Looks like your file is a C# file and you’ve written your code in JavaScript.

Even with that fixed you’re calling Shoot() but your function name is Shot()

Here’s the C# equivalent:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class bulletscript : MonoBehaviour {

 public Transform Bullet;
 public Transform Spawn;

  void Update ()
  {
    if(Input.GetButtonDown("Fire1"))
    {
      Shoot();
    }
  }
  void Shoot()
  {
     var pel = Instantiate(Bullet, Spawn.position, Spawn.rotation);
     pel.rigidbody.AddForce(transform.forward * 8000);
  }
}

@Jinkata it said it is using obsolete api’s… it is on line 20. is there another way to do that?

what buton on the keyboard is “fire 1” i dont know it