EventInstance isn't valid when referencing it after instantiation

I have a class that instantiates objects with a StudioEventEmitter on it. I’m trying to modify a parameter on an EventInstance after instantiation, however it isn’t valid for some reason. The event is one shot.

From Character.cs. FmodEventInstance here is not valid.

private void HitSound(Character victim, bool isCrit)
{
var slashSound = Instantiate(slash);
slashSound.transform.position = victim.transform.position;
var FmodEventInstance = slashSound.GetComponent().EventInstance;
FmodEventInstance.setParameterByName(“CriticalBool”, 1f);
}

From SlashAudio.cs. This one is valid. It is attached to the instantiated object.

private EventInstance FmodEventInstance;

void Start()
{
FmodEventInstance = GetComponent().EventInstance;

var pitchParameter = Random.Range(0f, 1f); FmodEventInstance.setParameterByName(“Pitch”, pitchParameter);

}

Can anyone let me know why the top one doesn’t work? And how I can get it to work? Thanks.

Edit: For some reason it won’t let me add StudioEventEmitter to GetComponent in this text editor, just pretend that’s there.

Fixed it by setting the emitter on the prefab to not play on awake, and then running Play() followed by SetParameter() on the emitter, as opposed to on the EventInstance.