How do you remove a script from one gameobject and then store it as a variable on another. So a player hits one game object which is a pickup containing a class of pickup and store it in a variable on the player and destroy the pickup. I tried but it seems thatt when I destroy the pickup the script says missing in the UI.
Components always need to be associated with a game object - so it sounds like what you actually need is a class that isn’t derived from MonoBehaviour to hold your pickup - this can then be moved between your items:
#Pickup.cs#
[Serializable]
public class Pickup
{
public int someValue;
public string someOtherValue;
}
#PickupBehaviour.cs#
public class PickupBehaviour : MonoBehaviour
{
public Pickup itemToBePickedUp;
}