Dictionary KeyNotFound error

Hello there! I’m using a Dictionary to keep track of friendships between different NPCs in the game but I seem to run into an issue when actually looking for those game objects.

manager.characterOwner.friendships[otherChatter] += friendshipValue;

This is the line of code that actually does the search, it’s important to note that [otherChatter] is a gameobject that is the key in question. It simply just takes the gameobject but it’s saying that the key was not present in the dictionary.

        friendships = new Dictionary<GameObject, float>();
        foreach(GameObject npc in CharacterSpawner.instance.characters.Where(s => s.gameObject != gameObject))
        {
            if(npc != gameObject)
            {
                friendships.Add(npc.gameObject, 0);
            }
        }

but this is the code that adds the gameobject to the dictionary. So I don’t get how the gameobject doesn’t exist when the same code that spawns the characters and adds them to the dictionary are the same.

Sorry about the inexperience! Would love help please