> For the complete documentation index, see [llms.txt](https://kdoore.gitbook.io/cs2335/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kdoore.gitbook.io/cs2335/cs2335_f20/project1-enhancements/pickup-selfdestruct.md).

# PickUp - SelfDestruct

```java
[DisallowMultipleComponent] //only one of these scripts allowed on a gameObject
public class PickUp : MonoBehaviour {

    //Unity manages creation of components so no constructors
    public int Value;  //different for every game object instance - set in inspector

    private void Start() //this will cause pickups to self-destruct after random range of seconds
    {
        Invoke("DestroyMe", Random.Range(3, 7));
    }

    public void DestroyMe()
    {
        Destroy(gameObject);
    }

}
```
