Turn on and off Scripts with code

I am using the tutorial of the platform game.

For example, you need to assign “Third Person Player Animation” and “Third Person Controller” to the main character.

I currently have 3 different “Main Characters”, and I have the camera switching between all three. This issue is, when I walk around, all 3 of them are moving at the same time.

I was thinking if I deactivate the scripts when the character is not the main player, that would work but I do not know how to do that in code.

Any thoughts?

Thanks!

Hallo,

maybe u can use this script as a base for your script:

function Update(){
if (Input.GetKeyDown ("f")){ 
     
myScript = camera.GetComponent("MouseLook");      
    
    myScript.enabled = ! myScript.enabled;

}


}

Thanks! That was exactly what I needed!