Can an object have variables, or can only scripts of that object have variables?

edit: nevermind please delete

Variables are part of components, that is right. So you will definitely need to attach those components to your gameObjects.

However you should not make that GetComponent call once needed, but instead cache it in Start() or Awake() like

private HealthComponent health;

void Awake() {
	
	health = GetComponent<HealthComponent>();
	
}

and then you might use a method like this

void IncreaseHealth() {
	health.life += 1;
}

That’s Unity’s way of creating flexible gameObjects which can be used for nearly any purpose. I like that approach rather than having pre-defined “player” or “npc” objects you can pull in and which might have tons of unnecessary code, references and perfomance hits on them you actually don’t need.