Floriian Posted May 7, 2020 Posted May 7, 2020 (edited) Hi, (again me 😅) I have some problem with this code. What can I do? (Version: 1.1) System.NullReferenceException: 'Object reference not set to an instance of an object.' XpertRoleplay.Data.Data.PlayerData.get returned null. using System; using System.Collections.Generic; using System.Text; using GTANetworkAPI; namespace XpertRoleplay.Data { class Data { public static readonly String DataIndentifier = "PlayerInfo"; public Player PlayerData { get; set; } public String Name { get; set; } public int Cash { get; set; } public int Level { get; set; } public int Age { get; set; } public int Health { get; set; } public Data(Player player) { this.PlayerData = null; this.Name = ""; this.Cash = 0; this.Level = 0; this.Age = 0; this.Health = 0; } public void SetHealth(int health) { this.Health = health; this.PlayerData.Health = health; //This line } } } serverconsole: Object reference not set to an instance of an object. Object reference not set to an instance of an object. Edited May 7, 2020 by Floriian
Xabi Posted May 7, 2020 Posted May 7, 2020 How can you edit a property in a null object? this.PlayerData = null; 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now