Help with GUI script

heyy everyone i need help i am trying to make a script that when i talk to an npc and press ok in a gui.button it disables/enables a script from another object this works if the object is a child of the npc but i can’t have it as a child.

so what i need to no is how to disable a script from another script that belongs to a different object.

any help is much appreciated.

If you have a reference to that object, just use nPCGameObject.SendMessage(“TurnOn”); or nPCGameObject.SendMessage(“TurnOff”); and have functions named TurnOn and TurnOff inside the NPC script that handles switching the GUI. Usually they’d just set a boolean to true or a boolean to false.

ok thanks i will try this soon.

ok thanks for all you’re help but i figured out another way.

all i did was make both scripts part of the character than added a var target : transform and made a distance thing so when i am within 5 of that object the script is then enabled and the text auto appears.

here is the code for anyone who want’s it just replace the “Mask button” with you’re own script

var target : Transform;

function Update () {
var other = gameObject.GetComponent("Mask button");

if ( Vector3.Distance(target.position, transform.position ) < 5) {
other.enabled = true;
}
}

Be sure to keep in mind, that’ll be a performance issue if you make a lot of talking NPCs. For just one that’s totally fine, though.

ahh i see well luckily i only plan to do it a max of 4 times for key parts of the game the rest of the npc’s you have to click on to talk to. these other 4 npc’s only have this because they are key to the game.

thanks for all you’re help.