Any idea why this is spitting out null reference exceptions?

NullReferenceException: Object reference not set to an instance of an object
LookAtTarget.Fire () (at Assets/Scripts/LookAtTarget.cs:26)

 using System;
    using UnityEngine;
    
    public class LookAtTarget : MonoBehaviour
    {
    	public Rigidbody2D projectile;
    	public float speed = 1000;
    	public Transform target;
    
    	void Start() 
    	{
    		InvokeRepeating("Fire", 3, 0.5f);
    	}
    	void Update()
    	{
    		if(target != null)
    		{
    			transform.LookAt(target);
    		}
    
    		
    	}
    	void Fire()
    	{	
    		Rigidbody2D instantiatedProjectile = Instantiate(projectile,transform.position,transform.rotation)as Rigidbody2D;
    		instantiatedProjectile.velocity = new Vector2(instantiatedProjectile.velocity.x,3);
    	}
    
    }

Add some debugging code, is it possible you’re attaching somethign that isn’t a rigidbody2d? Try an transform or gameobject instead.

Use this to see what the output is in the console:

void Fire()
{ 
	if (projectile == null)
	  Debug.Log("Projectile is null");
	else
		Debug.Log("Projectile is NOT null");
		
	if (transform == null)
		Debug.Log("Transform is null");
	else
		Debug.Log("Transform is NOT null");
		
	Rigidbody2D instantiatedProjectile = Instantiate(projectile,transform.position,transform.rotation)as Rigidbody2D;
	
	if (instantiatedProjectile == null)
		Debug.Log("instantiatedProjectile is null");
	else
		Debug.Log("instantiatedProjectile is NOT null");
	
	instantiatedProjectile.velocity = new Vector2(instantiatedProjectile.velocity.x,3);
}