I have a little problem here that I've been trying to fix for past couple of hours. I'm using Unity 5 and c# to code with.
I have PlayerScript which has health/thirst/hunger values for the player.
I also have another script that works as the inventory. I've added the item "water" which you as a player can consume.
Here's some code for you to understand more:
public float health = 100f;
public float hunger = 100f;
public float thirst = 100f;
if (consumeEffects[i] == "DrinkItem")
GameObject.Find ("FPSController").GetComponent<PlayerScript>().thirst += 25.0f;
Debug.Log("You drank some water!");
With the Image upload in your comment section,
PlayerScript is not attached your FPSController GameObject. That's why
GetComponent<PlayerScript>() is failing. You must attach
PlayerScript script to your FPSController GameObject.
You can either do that from the Editor or through script in the