Button then instanitates gameobject

I have two gui buttons at the moment within my weapon window. I have two problems.

  1. When i click somewhere on the map the gameobject i instantiate goes halfway through the ground.

  2. When i click a button then click the other one my gameobject still instantiates even though im clicking buttons.

code:

// Update is called once per frame
void Update()
{
    if (button == true)
    {
        onMap = false;

        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit = new RaycastHit();

        if (Physics.Raycast(ray, out hit))
        {
            if (Input.GetMouseButtonDown(0))
            {
                Instantiate(weapons[0], hit.point, Quaternion.identity);
                onMap = true;
            }

            if (onMap == true)
            {
                button = false;
            }
        }
    }
    if (button1 == true)
    {

        onMap = false;

        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit = new RaycastHit();

        if (Physics.Raycast(ray, out hit))
        {
            if (Input.GetMouseButtonDown(0))
            {
               //if (!onMouseOver)
                //{
                    Instantiate(weapons[1], hit.point, transform.rotation);
                    onMap = true;
               // }
            }

            if (onMap == true)
            {
                button1 = false;
            }
        }
    }
}

void OnGUI()
{
    if (displayWeaponCache)
    {
        weaponWindowRect = GUI.Window(WEAPON_CACHE_ID, new Rect(Offset, Screen.height - (Offset + weaponWindowHeight), Screen.width - (Offset * 2), weaponWindowHeight), WeaponCacheWindow, "Weapons");
    }

    if (GUI.Button(new Rect(575.0f, 5.0f, 25.0f, 25.0f), "X"))
    {
        displayWeaponCache = !displayWeaponCache;
    }
}

public void WeaponCacheWindow(int winID)
{
    if (GUI.Button(new Rect((buttonWidth - 10), (buttonHeight - 10), buttonWidth, buttonHeight), "Turret1")) 
    {
        button = true;
        button1 = false;
        onMap = false;
    }
    if (GUI.Button(new Rect((buttonWidth + buttonWidth + 5), (buttonHeight - 10), buttonWidth, buttonHeight), new GUIContent(square))) 
    {
        button1 = true;
        button = false;
        onMap = false;
    }
}

}

Also using code like this how do i make it so i cnt plant gameobjects in the path of the enemy.

i got this to work i while back i will just make it answered :)