Nested Functions

Firstly, heres my code:

var target : StartSprite;
var targetScript : ChangeSprite;
var AcceptInput : boolean = true;
private static var score : int = 0;
var guiScore : GUIText;

function Awake () {

    function OnMouseDown () {
        if(!AcceptInput)
        {
            return;
        }
        AcceptInput = false;
        
        if(target.spriteRenderer.sprite == target.diamond) {
            score +=1;
            guiScore.text = "Score: " + score;
            yield WaitForSeconds (0.5);
            targetScript.enabled = true;
        }
        else {
            yield WaitForSeconds (0.5);
            targetScript.enabled = true;
            Debug.Log("Wrong Answer");
        }
    }
    function OnMouseUp () {
        AcceptInput = true;
        targetscript.enabled = false;
        changeSprite ();
    }
}
}

function changeSprite (){
    function OnMouseDown () {
        if(!AcceptInput)
        {
            return;
        }
        AcceptInput = false;
        if(target.spriteRenderer.sprite == target.diamond) {
            score +=1;
            guiScore.text = "Score: " + score;
            yield WaitForSeconds (0.5);
            targetScript.enabled = true;
        }
        else {
            yield WaitForSeconds (0.5);
            targetScript.enabled = true;
            Debug.Log("Wrong Answer");
        }
        function OnMouseUp () {
            AcceptInput = true;
            targetscript.enabled = false;
            changeSprite ();
        }
    }
}

Theres a compiling error with nested functions. I searched this up on the internet. I heard that you can’t use nested functions in unityscript. I’m a newbie to this. Does anyone have anyway to make the same effect? I really don’t know what to do. What’s an alternative to nested functions?

Yeah, function cannot be called inside other function, so you will either need to take them out or for example where your call

function OnMouseUp()
{
   blah blah blah
}

will need to ba changed to

if(Input.GetMouseButtonUp((0)
{
     blah blah blah
}

Hope this helps!