How to Active a script?[SOLVED]

Hello

I need help to active a script.
I muss made that when i take a pistol it can shot only when i take it this way i need a script that when i pick the pistol muss active the ScriptShot and when i drop the pistol muss it going False.

Any Suggestion Thanks

Hi!

your post is not very informative, it would be great if you could add more context.

if by activate a script you mean make the script actually do something in game, you need to attach the script to a game object.

click on the game object you want to add this script to, and view it in the inspector. by default its on the right of editor:

after that, click the “Add component” button to reveal the drop down list.
in there, type the name of your C# script and it will attach to the game object:

in this example, I’ve added a script called “Timer” to my game object.

you’ll know you succeeded when the component is shown in the inspector:

if this was not what you meant, please add more details, such as:

1.The script that is not working
2.what you expect to happen
3.what actually happens.

Thanks but i need how to active a script and not how to add :slight_smile:

But Thanks

I meen with active the script with a script But i need a variable but i dont know what for a varible muss i take:

public bool xxx or public SCRIPTNAME xxx

Ok Thanks

Not sure what this means, but this is SUPER-basic stuff regardless of what it means.

Here are some GREAT starting points for your learning journey:

Imphenzia / imphenzia - super-basic Unity tutorial:

https://www.youtube.com/watch?v=pwZpJzpE2lQ

Brackeys super-basic Unity Tutorial series:

https://www.youtube.com/watch?v=IlKaB1etrik

Sebastian Lague Intro to Game Development with Unity and C#:

I see it yet Thanks

I SOLVED THE PROBLEM:

public yourNameScript WhatYouWouldName;

void Update(){
   WhatYouWouldName.enabled=true //or false what you have need  
}
1 Like