1st person to third person toggle error

I am trying to make a script that lets me toggle between my first and third person camera but i get three errors
error CS0029: Cannot implicitly convert type ‘bool’ to ‘cameratoggle’
CS0119: ‘Input.GetKeyDown(KeyCode)’ is a method, which is not valid in the given context
CS1061: ‘bool’ does not contain a definition for ‘enabled’ and no accessible extension method ‘enabled’ accepting a first argument of type ‘bool’ could be found (are you missing a using directive or an assembly reference?)

Any help would be greatly appriciated, i am still very new to unity so i may not nderstand all of the terms yet.

using UnityEngine;
using System.Collections;

public class cameratoggle : MonoBehaviour
{
    public cameratoggle fpsCamera;
    public cameratoggle tpsCamera;
    bool fpsCam = true;

    // Use this for initialization
    void Start()
 
    {
       fpsCamera.enabled = fpsCam;
       tpsCamera = !fpsCam;

         // Update is called once per frame
            void Update()
        {


           if (Input.GetKeyDown.G)
             fpsCam = !fpsCam;
             fpsCam.enabled = fpsCam;
             tpsCamera.enabled = !fpsCam;

        }

     }
 

}

Line 6 and 7, don’t you intend those to be just Camera components rather than instances of this script? I assume you only have ONE of this script.

Also, you probably mean:

fpsCam = !fpsCam;

After taking yor advice, all three errors are still present, any advice on how to get rid of them?

Always look to the docs for errors with built-in methods like GetKeyDown:
Unity - Scripting API: Input.GetKeyDown

fpsCam = !fpsCam;

if you even need that, I’m not sure what you’re trying to do there. fpsCam is a bool, and fpsCamera is the camera, which has a property .enabled. Bools don’t have that property.

The above question makes me think perhaps you have no idea what is happening in this code.

Did you write this code? If you did, here is how to understand compiler and other errors and even fix them yourself:

https://discussions.unity.com/t/824586/8

If you did not write this code, just delete it, it’s horribly broken. Start afresh from a good new tutorial. There’s no value for anyone here to have you proxy-edit broken code that you think might do something but you’re not really sure.

its look he/she try to make opposite enabled on tpsCamera after fpsCamera was actived

//fpsCamera.enabled = fpsCam;
//tpsCamera = !fpsCam;

fpsCamera.enabled = fpsCam;
tpsCamera.enabled= !fpsCam;

and then he/she use the worng name and miss if state {}

if (Input.GetKeyDown.G)
             fpsCam = !fpsCam;
             fpsCam.enabled = fpsCam;
             tpsCamera.enabled = !fpsCam;

if (Input.GetKeyDown.G)
{//<----missing
             fpsCam = !fpsCam;
             fpsCamera.enabled = fpsCam;
             tpsCamera.enabled = !fpsCam;
}//<----missing

or maybe he/she want to switch fpsCam propertie inside the class too, but it private and he/she cant find it

To be honest, its the third tutorial i followed to try ad get it too work and it still hasnt worked so im not very sure how to get it to work, i just want the ability to toggle between my first and third person camera.

Looking closer at your code and the indentation whackiness, you have your Update() method inside your Start() method. Pull it out and make it a peer function to it, just another class function alongside Start(), just the way an empty script does. Don’t put any functions inside other functions. Unity cannot call function within functions.