I need help triggering audio from another object

I’m trying trigger another gameobject’s audiosource. Should seem simple but I know nothing about coding. I found this script which seems it should work but the “Player” part is confusing. I have a gameobject tagged as Player, but unclear as to what it’s referring too or how to code it. If anyone has an easier way of doing it I’m all ears.

Here’s the code I found:

using UnityEngine;
using System.Collections;

public class NoiseTrigger : MonoBehaviour {
public AudioSource source;

public void OnTriggerEnter(Collider other) {
	if (other.gameObject.GetComponent<Player>() != null) {
		source.Play();
	}
}

}

Change your code to the following :

public class NoiseTrigger : MonoBehaviour { 

AudioSource source;

 public void OnTriggerEnter(Collider other) {
     source = other.gameObject.GetComponent<AudioSource>();
     //Only play if it is not already playing
     if (!source.isPlaying) {
         source.Play();
     }
 }
}

I really appreciate the help but for some reason it’s still is not play when I hit the collider box. I double check that the box is ticked “Is Trigger” and it plays the audio when I tick the “Play On Awake” so I know the audio can be heard. I’m developing for Google VR if that has anything to do with it.

Here’s my Script that I have on the Trigger box.
using UnityEngine;
using System.Collections;

public class NoiseTrigger : MonoBehaviour {

public AudioSource source;

public void OnTriggerEnter(Collider other) {
	source = other.gameObject.GetComponent<AudioSource>();
	//Only play if it is not already playing
	if (!source.isPlaying) {
		source.Play();
	}
}

},I really appreciate the help but for some reason it still won’t play. I’m developing for Google VR if that has anything to do with it. I test the audio to make sure I could hear it and the sound plays on “Play On Awake” not sure why it’s not playing. :frowning:

Here’s the revised script
using UnityEngine;
using System.Collections;

public class NoiseTrigger : MonoBehaviour {

public AudioSource source;

public void OnTriggerEnter(Collider other) {
	source = other.gameObject.GetComponent<AudioSource>();
	//Only play if it is not already playing
	if (!source.isPlaying) {
		source.Play();
	}
}

}