Invisibility / renderer giving me a headache

Im a newcomer to coding and im trying to use a variable to turn of a mesh renderer… but when i test the Scene the object starts invisible when it should be hidden after a variable is changed. the object re-appears when i remove one line. see below and any help would salvage my sanity??

var myMeshRenderer:MeshRenderer;

var RenderMesh:boolean = true;

function Start ()



function Update ()
if (CrateStop.GlobalboxSwitch2 == true);

//myMeshRenderer.enabled = false;


You need to learn scripting.

Your script says

  1. RenderMesh is true.

  2. Every frame, switch off myMeshRenderer if CrateStop.GlobalboxSwitch2 is true.

RenderMesh never does anything (and should be written renderMesh for consistency)

Most probably, CrateStop.GlobalboxSwitch2 is true… But why check that every frame? Function Update should be used sparingly (mainly for input).