How do you activate a particle system while holding a key and how to activate audio holding a key?

I am designing a space game with a friend and would like to know how would you about of making a script which makes it when i hold “z” (When the spaceship moves forward) audio plays and how do i make a particle system activate when i hold “z” as well

  • note i want the sound and particle system to stop on release of the key
    e.g. hold “z” engine sound effect plays and particle system on the engine starts then they both stop when i release “z”

Thanks :smiley:

An example script (you will have to fill in the details):

/*You need to set the emit of this particle system to 0 at the editor,
so it will not emit at all during play-mode by itself*/

public ParticleSystem thruster; 

/* The audio, I am not sure about this one as I have little experience 
with audio (but you can google on how to play audio in unity*/

public AudioSource audio;

void Update() {

   if( Input.GetKey( KeyCode.Z) ) {
      thruster.Emit(10); //Emit some particle