Help Wanted With Code

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Linq;
using HoldemHand;

public class GameManager : MonoBehaviour
{
    public DeckScript deckScript;
    private CardScript[] allCards = new CardScript[7];
    private CardScript[] boardCards = new CardScript[5];
    private List<Hand> equalHands = new List<Hand>();
    private string boardString = "";
    private List<Hand> handList = new List<Hand>();
    [SerializeField]
    private List<PlayerScript> playerScripts = new List<PlayerScript>();
    private Dictionary<PlayerScript, Hand> keyValuePairs = new Dictionary<PlayerScript, Hand>();

    public void DealClicked()
    {
        ResetGame();
        for (int i = 0; i < playerScripts.Count ; i++)
            playerScripts[i].StartHand();// player gets cards
        deckScript.DealCommunityCards();
    }
    public void Check()
    {
       
        for (int i = 0; i < deckScript.communityCards.Length; i++)
        {
            boardCards[i] = deckScript.communityCards[i];
            boardString += boardCards[i].Formatting();
            if (!(i == allCards.Length)) boardString += " ";
        }

        //Hand h1 = new Hand(player1Script.GenerateFormatting(), boardString);
        //Hand h2 = new Hand(player2Script.GenerateFormatting(), boardString);

        StoreHandValues();
        CompareHandValues();
       
        /*       
                for(int i = 0; i < boardCards.Length; i++)
                {
                    boardString += boardCards[i].Formatting();
                    if (!(i == allCards.Length)) boardString += " ";
                }
        */

        //Debug.Log("h1: " + h1.HandTypeValue);
        //Debug.Log("h2: " + h2.HandTypeValue);
        //if (h1 > h2) Debug.Log("h1 > h2");
        //else Debug.Log("h2 > h1");
    }

    private void StoreHandValues()
    {
        keyValuePairs.Clear();
        for (int i = 0; i < playerScripts.Count; i++)
        {
            handList.Add(new Hand(playerScripts[i].GenerateFormatting(), boardString));
            keyValuePairs.Add(playerScripts[i], handList[i]);
        }
    }

    private Hand CompareHandValues()
    {
        Hand largestHand = keyValuePairs.Values.Max();
        var repeats = keyValuePairs.GroupBy(x => largestHand).Where(x => x.Count() > 1);
        if (repeats != null)
        {
            Debug.Log("pot is shared");
        }
        else
        {
            Debug.Log("as usual");
        }
        return largestHand;
    }

    private void ResetGame()
    {
        deckScript.Shuffle();
        foreach (PlayerScript playerScript in playerScripts)
            playerScript.ResetHand();
        deckScript.ResetDeck();
    }
}

Hi all, this is my GameManager script. It has no errors initially, but when I go into runtime and call the Check() function, there is an argument null exception that occurs at line 69. May I know what is causing the issue?

https://forum.unity.com/threads/how-to-fix-a-nullreferenceexception-error.1230297/

Something is null, just follow the steps to figure out what. We can throw stuff at you all day long, but you really just need to start debugging stuff and you’ll eventually get what is null. :slight_smile:

I will note, the error in your screenshot does not seem to be related to the script you’ve posted.

The other script that is used to evaluate the poker hand is extremely long. I found it from this site:

Basically, it evaluates the hand for me by returning a numerical value when i parse in the card strings, and I don’t think the error will come from there.