Gui logic problem

Ok what i am trying to do is set it up so i can click a character then when it is clicked 2 GUI buttons pop up and ask Confirm or Go Back. The problem i am having is when you click you can click over and over again making more Gui buttons pop up. please help... heres the code: Oh yea i also want to make it so i cant click another Character while you have one clicked (There are 4 characters). Ive tried adding if statements before the buttons are created but it results in still being able to click a different character and an error that states that "GUI functions can only be called from OnGUI". Please tell me if there is a better way of going about this... :D

Script 1

var startlook : Transform;

var clickeffect : Transform;

static var clickedclass : Transform;

//Look at target

function OnMouseOver () {

Test2.targ = transform;


// Look away from target

function OnMouseExit () {

Test2.targ = startlook;

isover = false;


function OnMouseUp () {

clickedclass = transform;


// This controls the special effect for when you click

var clickedeffect = Instantiate(clickeffect,transform.position,transform.rotation);


// Gui controls

function OnGUI () {

// if a class is clicked ask if you want to confirm or deny

    Debug.Log("Clicked Confirmed");

    if(GUI.Button(Rect(10,70,60,60),"Go Back")){
    Debug.Log("Clicked Go Back");



Script 2

static var targ : Transform;

function Update () {

//Makes what ever this script is attached to look at the target assigned



Don't call OnGUI yourself, let the system do that for you.

I would have a separate class (script) that manages the GUI and character selection. It's that, or you'll have to have each character signal each other that they have been clicked to inhibit others being clicked. A 'gui manager' script can keep a variable about which (if any) character is selected and display the appropriate buttons.