having difficulties accessing a non static variables value to save and load.

void Start()
{
GameObject idlescriptgoeshere = GameObject.Find (“powercost”);
TapPowerUpgradeManager tapPowerUpgradeManager = TAPPOWERManagerGOEShere.GetComponent ();
TapPowerUpgradeManager.cost += powerCost;
}

This is the code that I am using. What i am attempting to do is access the variable cost in my TapPowerUpgradeManager script. It is not a static variable, and I was told that i could access it this way. I am wanting to make the cost variable equal to the powercost private variable in this script so that i can then save it and load it using playerprefs. I can not just access it straight up and save it beacuse its not a static variable. I am un sure how i can access the variables stored value and save it through my save script when its not static. I cant make this particular variable static either.

Could someone please give me some ideas of how to make this work so that i can save and load that variables value? thank you!

Change TAPPOWERManagerGOEShere to idlescriptgoeshere

cost isn’t static, so change TapPowerUpgradeManager.cost to tapPowerUpgradeManager.cost

Make sure cost is a public variable

   TapPowerUpgradeManager tapPowerUpgradeManager = (TapPowerUpgradeManager) idlescriptgoeshere.GetComponent<TapPowerUpgradeManager> ();
   tapPowerUpgradeManager.cost += powerCost;