C# script don't work

Hi guys,

i made this :

using UnityEngine;
using System.Collections;

public class Temps : MonoBehaviour
{
   
    // Use this for initialization
    void Start ()
    {
       
       
       
    }
   
    public GameObject other;
   
   
    // Update is called once per frame
    void Update ()
    {
       
        for(int time; time < 4; time++)
        {
            if(time < 2)
            {
                gameObject.renderer.material.color = Color.red;
            }
           
            else if(time = 2)
            {
                gameObject.renderer.material.color = Color.yellow;
            }
           
            else if(time = 4)
            {
                gameObject.renderer.material.color = Color.green;
            }
           
            else if(time > 4)
               
            {
                Destroy(other);
            }
           
           
        }
       
    }
}

and when i drag and drop this file in my unity object it’s says : " can’t add component ‘Temps’ because it doesn’t exist. check to see if the file name and class name match.

How can I solve that please.
Thanks for replying.

Whats the filename for that script? Try renaming it to “Temps” in Project window.

1 Like