Play sound on mouse enter

Im really new to programming in unity javascript.

So I want that when I look at a object it makes a sound, and when I take the mouse away from it, it makes no sound.

I have a script made which does what I want but just the opposet, so could someone help me?

function OnMouseEnter() {
 
    audio.Stop();
}

function OnMouseExit() {

	audio.Play();
}

You have the functions muddled up, no biggie. Think about it logically “OnMouseEnter” means when the mouse enters the destination. You need to put your audio.Play in here and vice versa for the other.

function OnMouseEnter() {

    audio.Play();

}
 
function OnMouseExit() {
 
    audio.Stop();

}