Making projectiles

I am developing one of my games using Unity using 5.3.4. I am trying to figure out how to make projectiles when using a key such as space. What code would I have to use?

Try something along these lines:

    public GameObject projectilePrefab;
    public float speed;
    void Update()
        if (Input.GetKeyDown(KeyCode.Space))
            GameObject projectileObj = Instantiate(projectilePrefab, Camera.main.transform.position, Camera.main.transform.rotation, Camera.main.transform);
            Rigidbody rb = projectilePrefab.AddComponent<Rigidbody>();
            rb.AddForce(Camera.main.transform.forward * speed);