Need help, going in circles = Operator '+' cannot be used with a left hand side of type 'PlayerStatsV2' and a right hand side of type 'int'

Hello,
I am currently trying to work on getting a healing item to work, but it keeps giving me the above error. Im trying to get it that when I use “Steak” item, it adds +10 to Current Hunger. But no matter what I do, it gives me the same error. Ive looked around the forums that have similar problems, but none have worked for, and it will just return the same error.
Would someone please be kind enough to look at my 2 scripts and see what I am doing wrong?

Thank you. The error I get is on Line 29.

#pragma strict

//This script allows you to insert code when the Item is used (clicked on in the inventory).

var deleteOnUse = true;

private var playersInv : Inventory;
private var item : Item;
public var CurrentHunger : PlayerStatsV2;


@script AddComponentMenu ("Inventory/Items/Item Effect")
@script RequireComponent(Item)

//This is where we find the components we need
function Awake ()
{
	playersInv = FindObjectOfType(Inventory); //finding the players inv.
	if (playersInv == null)
	{
		Debug.LogWarning("No 'Inventory' found in game. The Item " + transform.name + " has been disabled for pickup (canGet = false).");
	}
	item = GetComponent(Item);
}

//This is called when the object should be used.
function UseEffect () 
{
	CurrentHunger += 10;


	Debug.LogWarning("<INSERT CUSTOM ACTION HERE>"); //INSERT CUSTOM CODE HERE!
	
	//Play a sound
	playersInv.gameObject.SendMessage("PlayDropItemSound", SendMessageOptions.DontRequireReceiver);
	
	//This will delete the item on use or remove 1 from the stack (if stackable).
	if (deleteOnUse == true)
	{
		DeleteUsedItem();
	}
}

//This takes care of deletion
function DeleteUsedItem()
{
	if (item.stack == 1) //Remove item
	{
		playersInv.RemoveItem(this.gameObject.transform);
	}
	else //Remove from stack
	{
		item.stack -= 1;
	}
	Debug.Log(item.name + " has been deleted on use");
}

Next is my script that I am trying to add the +10 CurrentHunger to. I apologize it is a bit long, but the current hunger variable is on Line 12.

#pragma strict


 var CurrentHP : float = 100.0;
 private var MaximumHP : int = 100.0;

 private var CurrentStamina : float = 100.0;
 private var MaximumStamina : float = 100.0;


// hunger for survival
private var CurrentHunger :float = 100.0;
private var MaximumHunger : int = 100;

// tempeture for survival 
var CurrentTemp :float = 100.0;
private var MaximumTemp : int = 100;

//fallrates for survival
var HungerFallRate : int = 4;
var TempretureFallRate : int = 3;


//bar textures (health bar, etc)
private var BarLength = 0.0;

    }

I hope someone can help me with this, I have been trying to resolve this for 2 days now, and have made 0 progress… :frowning:

Thank you for your time. :slight_smile:

public var CurrentHunger : PlayerStatsV2;

Looks like you are trying to add 10 to an instance of a script.

Use GetComponent to access the script instead. You can directly access the variable and add to it. Also, as CurrentHunger is used in the other script, call the above script instance something else to avoid confusion.

I managed to semi fix it. mostly having trouble with a variable unassigning itself when the game starts, but that’s ok… at least I made some progress.