Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Deactivating GameObject in Script doesn't Work

Discussion in 'Scripting' started by cate5171, Sep 21, 2020.

  1. cate5171

    cate5171

    Joined:
    Jan 5, 2020
    Posts:
    94
    Hey there!
    I need your Help!
    I am making a game and added a new thing to the player. This would make things in the game disappear from their screen but other players can see the objects. The problem is that the object doesn't disappear. When i try out in build or editor, everything else in the script works except for the line making the thing deactivate.
    Any ideas?
    Code (CSharp):
    1. GameObject.Find("Scriptedlock").SetActive(false);
     
    Last edited: Sep 21, 2020
  2. Yoreki

    Yoreki

    Joined:
    Apr 10, 2019
    Posts:
    1,628
    Are there any errors in the console? Is "Scriptedlock" spelled correctly? Is it the name of a gameobject, not a script?
     
  3. cate5171

    cate5171

    Joined:
    Jan 5, 2020
    Posts:
    94
    No errors, ScriptedLock is spelt correctly, it is a name of a gameobject
     
  4. cate5171

    cate5171

    Joined:
    Jan 5, 2020
    Posts:
    94
    Fixed it, the problem was the other parts of the script. They somehow "Blocked the current"
     
    Yoreki likes this.
unityunity