void OnDestroy() { PlayerPoints playerPoints = FindObjectOfType <PlayerPoints>(); if (playerPoints != null) { playerPoints.UpdatePoints(points); } }