Scripting help

So i am trying to A. count how many times a box goes into the goal when it hits a collider and B. when the counter gets up to 3 the mesh renderer of the box disappears. Can someone help me?

public class CubeMove : MonoBehaviour {

public GameObject Move;
public GameObject Pickup;
public GameObject New;
public int x = 0;

private void OnTriggerEnter(Collider other)
{
Move.transform.position = New.transform.position;
x = x + 1;
if (x = 3)
{
Destroy(Object.Pickup MeshRenderer);
}
}

Where’s your code to help you with?

You’re probably going to need this by the way:

Its saying unexpected symbol mesh renderer … i don’t understand why.

You probably want:

Pickup.renderer.enabled = false;

This probably also works, but I admit I’ve never tried to destroy a MeshRenderer:

Destroy(Pickup.GetComponent<MeshRenderer>());

Thanks!!! it works!!

your comparison was incorrect (for checking ‘3’).

if(x = 3) {

should be: if(x == 3)