Problems with setting variable in another script to value

I’m trying to edit the values of a script that I attach to a gameobject however, I get a NullReferenceException. Here’s the code where I’m calling the other script and it variables:

   if (go.GetComponent<attchas>() == null)
                    {
                        go.AddComponent<attchas>();
                        SimpleConsole.print("ATTACHED SCRIPT");
                        
                    }
                    poiList.Add(go);
                    SimpleConsole.print("ADDED POI TO LIST");
                    attchas test = GameObject.Find(param.getAtIndex(1).iData.ToString()).GetComponent<attchas>();
                    SimpleConsole.print("SET TEST");
                    test.sp.contactOffset = param.getAtIndex(3).fData;

SimpleConsole is the name of an Debug Console asset I’m using to test the various features of my program. SimpleConsole.print just prints to the console. With that said, it reaches “SET TEST” then thats when I get my error.
Heres the other script “attchas”:

using UnityEngine;
using System.Collections;

public class attchas : MonoBehaviour {
    public AudioSource ao = new AudioSource();
    public SphereCollider sp = new SphereCollider();
    void Update()
    {

            Vector3 pos1 = sp.transform.position;

            if (!ao.isPlaying & ao != null & sp != null & Vector3.Distance(GameObject.FindGameObjectWithTag("Player").transform.position, pos1) <= sp.contactOffset)
            {
                ao.Play();
            }
            else if (ao.isPlaying & ao != null & sp != null & Vector3.Distance(GameObject.FindGameObjectWithTag("Player").transform.position, pos1) > sp.contactOffset)
            {
                ao.Pause();
            }
        
    }
}

If anyone could give me a good idea of where to start investigating I would be grateful.

Rather than just printing out fixed messages “ADDED POI TO LIST”, “SET TEST” etc., you can make your Debug.Log commands more useful by printing out the value of variables at that point:

                 poiList.Add(go);
                 SimpleConsole.print("ADDED POI " + go.ToString() + " TO LIST");

                 attchas test = GameObject.Find(param.getAtIndex(1).iData.ToString()).GetComponent<attchas>();
                 SimpleConsole.print("FOUND THE ATTCHS COMPONENT ATTACHED TO " + param.getAtIndex(1).iData.ToString());

                 SimpleConsole.print("TRYING TO ASSIGN " + param.getAtIndex(3).fData.ToString() + " TO test.sp. contactOffset");
                 test.sp.contactOffset = param.getAtIndex(3).fData;

etc.

You shouldn’t be initializing components within a MonoBehavior like that. If you require them, you should be attaching them either in the editor, or via the AddComponent method. If you go about the AddComponent route you’d want to do that in the Start method.

Also it is often good practice to use:

[RequireComponent(typeof(AudioSource))]
[RequireComponent(typeof(SphereCollider))]

if your class absolutely requires those components. That way when this Component is attached to a GameObject, it will auto-attach the required components.