Error CS0103

Hi,

I’m getting a CS0103 error,Assets\Scripts\GameControl.cs(50,9): error CS0103: The name ‘scoreText’ does not exist in the current context
Here is my code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

public class GameControl : MonoBehaviour {
public static GameControl instance;

public GameObject gameOverText;

public bool gameOver = false;

public float scrollSpeed = -1.5f;

private int score = 0;

void Awake()
{
if (instance == null) {

instance = this;

} else if (instance != this)
{

Destroy (gameObject);

}
}

void Update()
{
if (gameOver == true && Input.GetMouseButtonDown (0))
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
}
}

public void BirdScored ()
{
if (gameOver)
{
return;

}
score++;
scoreText.text = “Score:” + score.ToString();
}

public void BirdDied()
{
gameOverText.SetActive(true);

gameOver = true;
}

}

Please use code tags when posting code (right there in the editor toolbar next to “Code:”).

And I’d say the error is correct. I see a declaration of gameOverText, but no declaration of scoreText.

PLs help me heres my code

using UnityEngine;
public class Target : MonoBehaviour
{
     public float health = 70f;   
     public void TakeDamage (float amount) 
     {
        health -= amount;
        if (health <= 0f) 
        {
           Die();
        }
     }
     void Die () 
     {
        Destory(gameObject);
     }
}

error: Assets\Target.cs(19,9): error CS0103: The name 'Destory' does not exist in the current context

You need to check your spelling.

is it without a caps in the tutorial is said it was with caps

nvm its not the caps

i am working on snake and ladder game with no experience and don’t know how to fix the error as below:
Assets\GameControl.cs(27,29): error CS0103: The name ‘Gameobject’ does not exist in the current context

the code is:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;

public class GameControl : MonoBehaviour
{

private static Gameobject whoWinsTextShadow, player1MoveText, player2MoveText;
private static Gameobject player1, player2;
public static int nofPlayers;

public static int diceSideThrown = 0;
public static int player1StartWaypoint = 0;
public static int player2StartWaypoint = 0;

public static bool gameOver = false;

// Use this for initialization
void Start ()
{
diceSideThrown = 0;
player1StartWaypoint = 0;
player2StartWaypoint = 0;
gameOver = false;

whoWinsTextShadow=Gameobject.Find(“WhoWinsText”);
player1MoveText = Gameobject.Find(“P1Move”);
player2MoveText = Gameobject.Find(“P2Move”);

player1 = Gameobject.Find(“Player1”);
player2 = Gameobject.Find(“Player2”);

player1.GetComponent().moveAllowed = false;
player2.GetComponent().moveAllowed = false;

whoWinsTextShadow.Gameobject.SetActive(false);
player1MoveText.Gameobject.SetActive(true);
player2MoveText.Gameobject.SetActive(false);
}

// Update is called once per frame
void Update()
{
if(gameOver)
{
whoWinsTextShadow = Gameobject.Find(“Try Again”);
}
if(Dice.whosTurn == 1){
player1MoveText.Gameobject.SetActive(true);
player2MoveText.Gameobject.SetActive(false);
}
else if(Dice.whosTurn == 2){
player1MoveText.Gameobject.SetActive(false);
player2MoveText.Gameobject.SetActive(true);

}
else if(Dice.whosTurn == 3){
player1MoveText.Gameobject.SetActive(false);
player2MoveText.Gameobject.SetActive(false);
}
else if(Dice.whosTurn == 4){
player1MoveText.Gameobject.SetActive(false);
player2MoveText.Gameobject.SetActive(false);
}
// Player 2
if (player2.GetComponent().waypointIndex > player2StartWaypoint + diceSideThrown)
{
if(player2StartWaypoint+diceSideThrown == 3){
player2.GetComponent().transform.position = player2.GetComponent().waypoints[24].transform.position;
player2.GetComponent().waypointIndex = 24;
player2.GetComponent().waypointIndex +=1;
MovePlayer(2);
}
if(player2StartWaypoint+diceSideThrown == 12){
player2.GetComponent().transform.position = player2.GetComponent().waypoints[45].transform.position;
player2.GetComponent().waypointIndex = 45;
player2.GetComponent().waypointIndex +=1;
MovePlayer(2);
}
if(player2StartWaypoint+diceSideThrown == 32){
player2.GetComponent().transform.position = player2.GetComponent().waypoints[48].transform.position;
player2.GetComponent().waypointIndex = 48;
player2.GetComponent().waypointIndex +=1;
MovePlayer(2);
}
if(player2StartWaypoint+diceSideThrown == 41){
player2.GetComponent().transform.position = player2.GetComponent().waypoints[62].transform.position;
player2.GetComponent().waypointIndex = 62;
player2.GetComponent().waypointIndex +=1;
MovePlayer(2);
}
if(player2StartWaypoint+diceSideThrown == 49){
player2.GetComponent().transform.position = player2.GetComponent().waypoints[68].transform.position;
player2.GetComponent().waypointIndex = 68;
player2.GetComponent().waypointIndex +=1;
MovePlayer(2);
}
if(player2StartWaypoint+diceSideThrown == 61){
player2.GetComponent().transform.position = player2.GetComponent().waypoints[80].transform.position;
player2.GetComponent().waypointIndex = 80;
player2.GetComponent().waypointIndex +=1;
MovePlayer(2);
}
if(player2StartWaypoint+diceSideThrown == 73){
player2.GetComponent().transform.position = player2.GetComponent().waypoints[91].transform.position;
player2.GetComponent().waypointIndex = 91;
player2.GetComponent().waypointIndex +=1;
MovePlayer(2);
}
if(player2StartWaypoint+diceSideThrown == 39){
player2.GetComponent().transform.position = player2.GetComponent().waypoints[2].transform.position;
player2.GetComponent().waypointIndex = 2;
player2.GetComponent().waypointIndex +=1;
MovePlayer(2);
}
if(player2StartWaypoint+diceSideThrown == 86){
player2.GetComponent().transform.position = player2.GetComponent().waypoints[36].transform.position;
player2.GetComponent().waypointIndex = 36;
player2.GetComponent().waypointIndex +=1;
MovePlayer(2);
}
if(player2StartWaypoint+diceSideThrown == 88){
player2.GetComponent().transform.position = player2.GetComponent().waypoints[52].transform.position;
player2.GetComponent().waypointIndex = 52;
player2.GetComponent().waypointIndex +=1;
MovePlayer(2);
}
if(player2StartWaypoint+diceSideThrown == 97){
player2.GetComponent().transform.position = player2.GetComponent().waypoints[40].transform.position;
player2.GetComponent().waypointIndex = 40;
player2.GetComponent().waypointIndex +=1;
MovePlayer(2);
}
player2.GetComponent().moveAllowed = false;
player2StartWaypoint = player2.GetComponent().waypointIndex - 1;
}
// ** PLAYER 1
if (player1.GetComponent().waypointIndex > player1StartWaypoint + diceSideThrown)
{
//Debug.Log(player1StartWaypoint+diceSideThrown);
if(player1StartWaypoint+diceSideThrown == 3){
player1.GetComponent().transform.position = player1.GetComponent().waypoints[24].transform.position;
player1.GetComponent().waypointIndex = 24;
player1.GetComponent().waypointIndex +=1;
MovePlayer(1);
}
if(player1StartWaypoint+diceSideThrown == 12){
player1.GetComponent().transform.position = player1.GetComponent().waypoints[45].transform.position;
player1.GetComponent().waypointIndex = 45;
player1.GetComponent().waypointIndex +=1;
MovePlayer(1);
}
if(player1StartWaypoint+diceSideThrown == 32){
player1.GetComponent().transform.position = player1.GetComponent().waypoints[48].transform.position;
player1.GetComponent().waypointIndex = 48;
player1.GetComponent().waypointIndex +=1;
MovePlayer(1);
}
if(player1StartWaypoint+diceSideThrown == 41){
player1.GetComponent().transform.position = player1.GetComponent().waypoints[62].transform.position;
player1.GetComponent().waypointIndex = 62;
player1.GetComponent().waypointIndex +=1;
MovePlayer(1);
}
if(player1StartWaypoint+diceSideThrown == 49){
player1.GetComponent().transform.position = player1.GetComponent().waypoints[68].transform.position;
player1.GetComponent().waypointIndex = 68;
player1.GetComponent().waypointIndex +=1;
MovePlayer(1);
}
if(player1StartWaypoint+diceSideThrown == 61){
player1.GetComponent().transform.position = player1.GetComponent().waypoints[80].transform.position;
player1.GetComponent().waypointIndex = 80;
player1.GetComponent().waypointIndex +=1;
MovePlayer(1);
}
if(player1StartWaypoint+diceSideThrown == 73){
player1.GetComponent().transform.position = player1.GetComponent().waypoints[91].transform.position;
player1.GetComponent().waypointIndex = 91;
player1.GetComponent().waypointIndex +=1;
MovePlayer(1);
}
if(player1StartWaypoint+diceSideThrown == 39){
player1.GetComponent().transform.position = player1.GetComponent().waypoints[2].transform.position;
player1.GetComponent().waypointIndex = 2;
player1.GetComponent().waypointIndex +=1;
MovePlayer(1);
}
if(player1StartWaypoint+diceSideThrown == 86){
player1.GetComponent().transform.position = player1.GetComponent().waypoints[36].transform.position;
player1.GetComponent().waypointIndex = 36;
player1.GetComponent().waypointIndex +=1;
MovePlayer(1);
}
if(player1StartWaypoint+diceSideThrown == 88){
player1.GetComponent().transform.position = player1.GetComponent().waypoints[52].transform.position;
player1.GetComponent().waypointIndex = 52;
player1.GetComponent().waypointIndex +=1;
MovePlayer(1);
}
if(player1StartWaypoint+diceSideThrown == 97){
player1.GetComponent().transform.position = player1.GetComponent().waypoints[40].transform.position;
player1.GetComponent().waypointIndex = 40;
player1.GetComponent().waypointIndex +=1;
MovePlayer(1);
}
player1.GetComponent().moveAllowed = false;
player1StartWaypoint = player1.GetComponent().waypointIndex - 1;
}
if (player1.GetComponent().waypointIndex == player1.GetComponent().waypoints.Count)
{
whoWinsTextShadow.Gameobject.SetActive(true);
whoWinsTextShadow.GetComponent().text = “Player 1 Wins”;
gameOver = true;
}
if (player2.GetComponent().waypointIndex == player2.GetComponent().waypoints.Count)
{
whoWinsTextShadow.Gameobject.SetActive(true);
whoWinsTextShadow.GetComponent().text = “Player 2 Wins”;
gameOver = true;
}

}

public static void MovePlayer(int playerToMove)
{
switch (playerToMove) {
case 1:
player1.GetComponent().moveAllowed = true;
break;

case 2:
player2.GetComponent().moveAllowed = true;
break;

}
}
}

please help somebody… :frowning:

There is no such type as “Gameobject” in Unity. There is a “GameObject” class, but that’s not what you typed.