Non-static member

This script is suppoused to activate a button, from a value of 25, if the value is to low, it’s suppoused to activate something else.

using UnityEngine;
using System.Collections;

public class RepairBuyButton : MonoBehaviour {

	public GameObject cam;
	public GameObject BuyButton;
	public GameObject NotReadyToBuy;

	public void BuyItemButton()
	{
		if (playerMoney.money >= 25) 
		{
			BuyButton.SetActive (true);
		}

		else 
		{
			NotReadyToBuy.SetActive (true);
		}
	}
}

The line with: if (playerMoney.money >= 25) is telling me :An object reference is required to access non-static member `playerMoney.money’. Help is appreciated.

Set up a public script and drag that script in the editor.

public NameOfScript playerMoney.

That or, make the “money” variable a static one.

The problem is that you are trying to use “playerMoney” which is not declare anywhere.

So it looks like that playerMoney is a class, so you can just define your money attribute like that :

public static float money;

in your playerMoney class.

I suppose that you have only one player, so this is a good solution.

BUT, if maybe one day you will need to have two players, then i highly recommend you to add an attribute in this class :

public PlayerMoney playerMoney;

and then, from the editor, you drag your script to the new field “playerMoney”.

You can do this only if your PlayerMoney inherit from MonoBehavior.