C# GetComponent / change values throught other script

Hello im trying to access/change the value of a variable in one script through another script which is my SceneManager.cs(lives is declared static in SceneManager.cs). Im having trouble figuring out why? Thanks.

public GameObject sceneManager;

void OnTriggerEnter (Collider other)
{
	if(other.gameObject.tag == "Player")
	{
		print("Collided");
		//other.GetComponent.("Player").laserOn = true;
		//other.GetComponent.("Player").bulletOn = false;

		SceneManager sm = gameObject.GetComponent("SceneManager")();
		sm.lives += 1;
		

		Destroy (gameObject);
	}

To retrieve a component I almost always use the following syntax:

//you don't need to access the gameObject reference, it makes you go another unecessary GetComponent call.

 SceneManager sm = this.GetComponent<SceneManager>();

However, if I read your quesiton correctly, you say that “lives” is declared static…so you don’t need that anyway, instead of:

SceneManager sm = gameObject.GetComponent("SceneManager")();
       sm.lives += 1;

Simply do:

SceneManager.lives += 1;

Try this:

SceneManager sm = (SceneManager)gameObject.GetComponent<SceneManager>();

It compiles…but when the condition is met on the OnTriggerEnter method it reads an error “Object is not set to instance of object.”