SetActive(true) not working

It seems that I am not able to reactivate the game object once I deactivate it. Is there a workaround?

void Update()
{
	if(Vector3.Distance(Player.transform.position, transform.position) <= 18f)
	{
		gameObject.SetActive(true);
	}
	if(Vector3.Distance(Player.transform.position, transform.position) >= 18.1f)
	{
		gameObject.SetActive(false);
	}
}

Since an inactive game object has all its components inactive, the script attached to it does not run anymore. This question was asked a lot of times, and answered a lot of times.

For example this answer will help you.

Attach the script to a different game object on the hierarchy, then create a new variable of type game object: public GameObject theObject

Then set theObject.SetActive(false);
And theObject.SetActive(true);