Component Enable/Disable?

First time using Unity with JavaScript and I am wondering how to enable/disable an Audio Source using Javascript. In my case I need to turn on the Audio Source when the mouse enters the collision area. :face_with_spiral_eyes:

Here is the script I have written and I am wondering if I can make the Audio Source get enabled and then disabled on exit.

function OnMouseEnter()
{

	renderer.material.color = Color.green;
	

}
function OnMouseExit()
{

	renderer.material.color = Color.white;

}

Thanks.

Use this to get component

var AudioSound : AudioSource; //drag AS here

and these to get it enabled/disabled

AudioSound.enabled=true;
AudioSound.enabled=false;

“//drag AS here” Dont quite know what you mean by this

You should see Audio Sound [None(audiosource)] in inspector-window…just drag gameobject that has audiosource-component to that slot.

Found it, Thank! :slight_smile: