How do I fix UnityEngine.Transform' does not contain a definition for `GameObject'?

I’ve looked all over for how to fix this error and every time I think I find a fix it creates a bunch more errors. So I figured I would just ask about it. Here is the script

using UnityEngine;
using System.Collections;

public class GameCamera : MonoBehaviour {
	private Transform target;
	public float trackSpeed = 25;
	public void SetTarget() {
		target = Transform.GameObject.FindWithTag ("Player");
	void LateUpdate() {
		if (target) {
			float x = IncrementTowards(transform.position.x, target.position.x, trackSpeed);
			float y = IncrementTowards(transform.position.y, target.position.y+2, trackSpeed);
			transform.position = new Vector3(x, y, transform.position.z);
	private float IncrementTowards(float n, float target, float a) {
		if (n == target) {
			return n;	
		else {
			float dir = Mathf.Sign(target - n);
			n += a * Time.deltaTime * dir;
			return (dir == Mathf.Sign(target-n))? n: target;

I need it to find the object with the Player tag so I can switch players and the camera will start following the new player. The error is:

‘UnityEngine.Transform’ does not contain a definition for ‘GameObject’

and it is pointing to this line:

target = Transform.GameObject.FindWithTag ("Player");

Any ideas on how I can fix this? I feel like I’ve tried everything, but it’s probably something simple. Thanks in advance for any help!

It’s because in most programming languages, case matters. GameObject is not the same thing as gameObject. GameObject is a class (kind of like the blueprint that defines all game objects), while gameObject is a variable, of type GameObject, which is a member of the Transform class (note that the same holds true of Transform, in that it is not the same thing as transform). Regardless, you don’t actually need that, as FindWithTag is a static method, meaning it can be called directly from the class GameObject (i.e. it doesn’t require a specific object). GameObject, as a class, is not contained within Transform, but is a separate entity. It just so happens that Transform objects contain a GameObject element, but the definition of GameObject is independent. Thus, you don’t need to look inside Transform to find it (which is what you’re doing when you write Transform.GameObject)

try this :

Tranform target;
GameObject Player;

Player = GameObject.FindWithTag (“Player”);
target = Player.transform;