/// <summary>Spawns a player.</summary>
        /// <param name="id">The player's ID.</param>
        /// <param name="username">The player's username.</param>
        /// <param name="position">The player's starting position.</param>
        /// <param name="scale">The player's starting scale.</param>
        /// <param name="animation">The starting animation of the spawned player.</param>
        /// <param name="charmsData">List of bools containing charms equipped.</param>
        public void SpawnPlayer(byte id, string username, Vector3 position, Vector3 scale, string animation, List <bool> charmsData, int team)
        {
            Log("spawnpl");
            // Prevent duplication of same player, leaving one idle
            if (Players.ContainsKey(id))
            {
                Log("spawnpl2");
                DestroyPlayer(id);
            }

            Log("spawnpll2");
            GameObject player = Instantiate(playerPrefab);

            Log("spawnpl3");
            player.SetActive(true);
            player.SetActiveChildren(true);
            // This component needs to be enabled to run past Awake for whatever reason
            player.GetComponent <PlayerController>().enabled = true;

            Log("spawnpl4");

            player.transform.SetPosition2D(position);
            player.transform.localScale = scale;

            if (Instance.PvPEnabled)
            {
                Log("Enabling PvP Attributes");

                player.layer = 11;

                player.GetComponent <DamageHero>().enabled = true;
            }
            if (Instance.TeamsEnabled)
            {
                Log("Enabling Teams Attributes");
                if (Instance.PvPEnabled)
                {
                    if (team != Client.Instance.team)
                    {
                        player.layer = 11;

                        player.GetComponent <DamageHero>().enabled = true;
                    }
                    else
                    {
                        player.layer = 9;

                        player.GetComponent <DamageHero>().enabled = false;
                    }

                    switch (team)
                    {
                    case 1:
                        player.GetComponent <tk2dSpriteAnimator>().Sprite.color = Color.red;
                        break;

                    case 2:
                        player.GetComponent <tk2dSpriteAnimator>().Sprite.color = Color.blue;
                        break;

                    case 3:
                        player.GetComponent <tk2dSpriteAnimator>().Sprite.color = Color.yellow;
                        break;

                    case 4:
                        player.GetComponent <tk2dSpriteAnimator>().Sprite.color = Color.green;
                        break;

                    default:
                        player.GetComponent <tk2dSpriteAnimator>().Sprite.color = Color.magenta;
                        break;
                    }
                }
            }

            player.GetComponent <tk2dSpriteAnimator>().Play(animation);

            GameObject nameObj = Instantiate(new GameObject("Username"), position + Vector3.up * 1.25f,
                                             Quaternion.identity);

            nameObj.transform.SetParent(player.transform);
            nameObj.transform.SetScaleX(0.25f);
            nameObj.transform.SetScaleY(0.25f);
            TextMeshPro nameText = nameObj.AddComponent <TextMeshPro>();

            nameText.text         = username;
            nameText.alignment    = TextAlignmentOptions.Center;
            nameText.fontSize     = 24;
            nameText.outlineColor = Color.black;
            nameText.outlineWidth = 0.1f;
            nameObj.AddComponent <KeepWorldScalePositive>();
            GameObject chatObj = Instantiate(new GameObject("Chattext"), position + Vector3.up * 2f,
                                             Quaternion.identity);

            chatObj.transform.SetParent(player.transform);
            chatObj.transform.SetScaleX(0.25f);
            chatObj.transform.SetScaleY(0.25f);
            TextMeshPro chatText = chatObj.AddComponent <TextMeshPro>();

            chatText.text         = "Chat Text";
            chatText.alignment    = TextAlignmentOptions.Center;
            chatText.fontSize     = 24;
            chatText.outlineColor = Color.black;
            chatText.outlineWidth = 0.1f;
            chatObj.AddComponent <KeepWorldScalePositive>();

            DontDestroyOnLoad(player);

            PlayerManager playerManager = player.GetComponent <PlayerManager>();

            playerManager.id       = id;
            playerManager.username = username;
            playerManager.chattext = chatText;
            for (int charmNum = 1; charmNum <= 40; charmNum++)
            {
                playerManager.SetAttr("equippedCharm_" + charmNum, charmsData[charmNum - 1]);
            }
            playerManager.team = team;
            Players.Add(id, playerManager);

            Log("Done Spawning Player " + id);
        }