// On click of ability keybind letter, allow player to change which ability they have public void ChangeAbility(string keyBind) { Image abilityIcon = GameObject.Find(keyBind + "Icon").GetComponent <Image>(); // Delete old ability if (abilityIcon.sprite != null) { Sprite oldAbility = abilityIcon.sprite; Destroy(player.GetComponent(oldAbility.name)); } // Add new player script, change keybind player.AddComponent(Type.GetType(newAbilityName)); abilityIcon.sprite = Resources.Load <Sprite>("Sprites/Abilities/" + newAbilityName); Abilities abilityToChange = (Abilities)player.GetComponent(newAbilityName); abilityToChange.ChangeKeybind(keyBind); Time.timeScale = 1f; gameObject.SetActive(false); }