call a function when object when destroy

hi
i search for metodh ,for call a function when a object is destoryed ,for example from another script or another object
in theory i need use something like
void WhenGameObjectIsDestroyed ()
{
/// code here

}

i search on google and manual,but maybe i don’t use the right keyword .
Thanks.

Perhaps this is what you want: MonoBehaviour.OnDestroy()