C sharp get and set problem: "name doesn not exist in the current context

Hello,

i got a problem with my code. I tried to make a get/set function for my
life variable, but the get, set and value is always marked as red, with the information: “The name get does not exist in the current context”

using UnityEngine;
using System.Collections;

public class PlayerController : MonoBehaviour {
    private int life;
   
    //return the life value
    public int Life() {
        get
        {
            return life;
        }
        set{
            life = value;

        }

    }
}

It’s thinking Life is a function because of your parentheses. :slight_smile: Use:

public int Life {
         get
         {
             return life;
         }
         set{
             life = value;
         }
     }