Make it Not possible for a player to activate the same ability too soon.

Hello, I don’t if I can explain this how I want to but here I go. I am trying to make it not possible a player to activate an ability twice even though if the player has met the requirements of doing the ability. For example changing characters is one ability that should not be activate-able for the next 10 seconds after its usage. What I’ve tried so far is use a system of if statements for the purpose of making a button press unusable with no luck. If someone could lend a hand in what I can do that would be awesome.Thanks in advance. Here is the code I am working on so people can see what I am talking about:

using UnityEngine;
using System.Collections;

public class ChangeToSecondForm : MonoBehaviour
{
//private bool secondFormAccessor;

private GameObject playerToBeChangedFrom;
private GameObject playerChangingTo;

public Transform secondFormDisplay;
public float maxEnergy = 100.0f;
public float currentEnergy;
private float energyOriginalXScale;

// Use this for initialization
void Start () 
{
	currentEnergy = 0.0f;
	energyOriginalXScale = secondFormDisplay.localScale.x;
	playerToBeChangedFrom = GameObject.FindGameObjectWithTag ("PlayerCharacter");
	playerChangingTo = GameObject.FindGameObjectWithTag ("PlayerCharacterSecondForm");
	playerChangingTo.SetActive (false);
	//secondFormAccessor = true;
}

// Update is called once per frame
void Update () 
{
	SecondForm ();
	//SecondFormAccess ();
}

/*public void SecondFormAccess()
{
	if (secondFormAccessor = true) 
	{
		SecondForm ();
	}
}*/

public void SecondForm()
{
	//secondFormAccessor = false;
	if (Input.GetButtonDown ("TransformToSecond") && (currentEnergy == 100)) 
	{
		Debug.Log("Q has been pressed");
		currentEnergy = 0;

		playerToBeChangedFrom.SetActive (false);
		playerChangingTo.SetActive(true);

		playerChangingTo.SendMessage ("TransformQueSound", true); 

		Invoke ("ChangeBack", 10.0f);
	}
	//secondFormAccessor = true;
}

public void ChangeBack ()
{
	playerToBeChangedFrom.SetActive (true);
	playerChangingTo.SetActive (false);
}

public void GatherEnergy(float energyGathered)
{

	currentEnergy += energyGathered;

	if (currentEnergy >= 100) 
	{
		currentEnergy = 100.0f;
	}
	Debug.Log ("Got Energy from dead enemy.");
}

}

While not being a complete solution, you might want to think about something like this:

public GameObject PlayerObject;
private GameObject playerToBeChangedFrom;
private GameObject playerChangingTo;
bool transformToFirst;

void Start ( )
{

    playerToBeChangedFrom = GameObject.FindGameObjectWithTag ( "PlayerCharacter" );
    playerChangingTo = GameObject.FindGameObjectWithTag ( "PlayerCharacterSecondForm" );
    // False indicates change to second.
    transformToFirst = false;
}

IEnumerator Transform ( )
{
    // Change the player
    Change ( );
    // Wait 5 seconds before transforming back
    yield return new WaitForSeconds ( 5.0f ); 
    // Change back
    Change ( );
}

void Change ( )
{
    playerChangingTo.SetActive ( transformToFirst );
    playerToBeChangedFrom.SetActive ( !transformToFirst );
    transformToFirst = !transformToFirst;
}

Then you’d work on the PlayerObject to move around your world. The other objects (playerChangingTo, playerToBeChangedFrom) would be children of the PlayerObject, and just activated/deactivated as needed.

Im assuming your asking for a “cooldown” type setup for skills.

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class CoolDown : MonoBehaviour {

    public float skillCoolDown = 10.0f;

    private float coolDownElapsedTime = 0.0f;

    protected void Start()
    {
        coolDownElapsedTime = skillCoolDown;  //  Allows for first time usage.
    }

	protected void Update ()
	{
        ActivateSkill();

        coolDownElapsedTime += 1 * Time.deltaTime;  //  Count up in seconds
	}

    protected void ActivateSkill()
    {
        if (Input.GetKey(KeyCode.Q) && coolDownElapsedTime >= skillCoolDown)  //  If we press our skill button and our cooldown is not still active then continue.
        {
            coolDownElapsedTime = 0.0f;  //  Reset our cooldown timer

            Debug.Log("We activated our skill.");
        }
        else if (Input.GetKey(KeyCode.Q) && coolDownElapsedTime <= skillCoolDown)  //  The cooldown is still active so notify us of how long it still has until reset.
        {
            Debug.Log("Cooldown time: " + (skillCoolDown - coolDownElapsedTime));
        }
    }
}

This is a simple cooldown system that i hope you can use or alter to your needs.