The name does not exist in the current context

Hey Guys. Iam pretty new into C# and I am just about to learn how to disable a script when something else is happening. so, currently iam working on a “place an object on a plane” script. some kind of orcs must die stuff.

so i have my third person controlled character and when he places an object he should not be able to move arround. so baisically i just need to disable the “ThirdPersonController”. but i have an error that says that The name does not exist in the current context

here ist the code snippet. the Disable ThirdPersonController Part is on line 32:

using UnityEngine;
using System.Collections;

public class BuildingPlacement : MonoBehaviour {

	public float scrollSensitivity;
		
	private PlaceableBuilding placeableBuilding;
	private Transform  currentBuilding;
	private bool hasPlaced;
	
	public LayerMask buildingsMask;
	public LayerMask groundMask;
	
	private PlaceableBuilding placeableBuildingOld;
	
	public float speed = 30; 
	
	
	// Update is called once per frame
	void Update () {
		
		RaycastHit hit = new RaycastHit();
 		Ray ray = camera.ScreenPointToRay (Input.mousePosition);
		Physics.Raycast(ray,out hit, Mathf.Infinity, groundMask);	
	
		Vector3 m = Input.mousePosition;
		m = new Vector3(m.x,m.y,transform.position.y);
		Vector3 p = camera.ScreenToWorldPoint(m);
		
		if (currentBuilding != null && !hasPlaced){
			Player.GetComponent("ThirdPersonController").enabled = false;
			//more stuff is comming here but thats not important i guess..

(the GameObject that contains the ThirdPersonController is called Player with a Tag that also called Player)
would be great if you have a look over and help me out with that :slight_smile:

You need to ‘find’ your Player gameobject first.

In function start() place your find object call and stick it into a new gameObject variable.

http://docs.unity3d.com/Documentation/ScriptReference/GameObject.FindGameObjectsWithTag.html

then when you GetComponent instead of using Player.GetComponent use newVariable.GetComponent

Also, it looks like you haven’t closed your BuildingPlacement function with a }
I’d say the same about update() but the… leaves it ambiguous. Remember that all functions are structured:

//.js
function myFunction(args)
{
     //your code
     optionalVar = args;

     return optionalVar; //return optional
}

You must close with opposing curly brace