Creating a list using a list from another script?

public static List LeaderPBA = new List() { RankingData.UserRankScore[0], RankingData.JoshuaRankScore[0], RankingData.WhyteRankScore[0], RankingData.FuryRankScore[0] };

Thats how im calling the list and stating whats within it below is how im getting the lists from the other script.

public static List<int> UserRankScore; //Score (Etc..........)

I dont see why this isnt working and i get this may be a long solution and a better fix but i am new to coding.

error it gives tells me to check “NullReferenceException” and the “object reference is not set to an instance of an object”

any help would be much appreciated

I hope this makes it more clear i cant work out why this error occurs?

Well the issue is pretty simple. You try to create and fill your “LeaderPBA” list inside a static field initializer. This will be evaluated way before the first object in your scene will be created / loaded / initialized. Furthermore static field initializers will most likely be executed from Unity’s loading thread because that will be the first time your class will be “touched”. It should be pretty obvious that at this time your static “UserRankScore” variable does not contain any list yet, let alone any useable data.

You should avoid static variables whenever possible, especially when you seemingly have no idea what they actually do or how they work ^^. You should move your list creation to some method which will be called after your other lists have been created and contain meaningful data. Since we don’t see anything else of your code this is where I will stop explaining.