I want ball to be invisible after colliding with goals?

So I have a game where the main idea is to get balls into goals. In one level, there are soccer goals all around. The balls need to disappear when they get in the nets. I have used a script called “Score” in C#, attached to the ball object and tried DestroyObject(gameobject) as that would make the balls disappear. However, I found it doesn’t always do it, especially after you restart the level. and does not seem like people online like people destroying objects like so. For my game, these balls do not need to respawn. Once they are gone, they are gone. Just restarting the level where everything resets, but that’s already done for me somewhere else. So here is what I had.

void OnCollisionEnter(Collision collision)
{
    if(collision.gameObject.name == "Goalposts" || collision.gameObject.name == "FootyGoals" ||
		   collision.gameObject.name == "GoalCollider" || collision.gameObject.name == "Goal ring") 
			
    {
Destroy (this.gameObject);

//I understand what gameobject.SetActive(false) could do, but it wouldn’t do the similar idea of making it invisible.
}
}

Hey, this will help you make the ball invisible - I don’t know if this will help, if it doesn’t, give me feedback and I will try to think of something else.

The ball has a material. You can manipulate the color of the material with code. However, in order to manipulate the alpha of the material, the shader has to be of the transparent type. Just click on the material that all your balls have and click on the drop down box, there you can choose the type “Transparent” and in there you can choose the same type your shader had been.
Once that is done, you can change the alpha by accessing the material’s color like so:

GetComponent<MeshRenderer>().material.color = new Color(GetComponent<MeshRenderer>().material.color.r,
			                                            GetComponent<MeshRenderer>().material.color.g,
			                                            GetComponent<MeshRenderer>().material.color.b,
			                                            GetComponent<MeshRenderer>().material.color.a);

You can set the color then - including the new alpha. The alpha is the 4th number in the Color() constructor and it is a float between 0 and 1.