Destroy gameObject not working?

var maximumHitPoints = 100.0;
var hitPoints = 100.0;
var deadReplacement : Rigidbody;
var GOPos : GameObject;
private var scoreManager : ScoreManager;

function Start(){

	var GO = gameObject.FindWithTag("ScoreManager");
	scoreManager = GO.GetComponent("ScoreManager");

function ApplyDamage (damage : float) {
	if (hitPoints <= 0.0)

	// Apply damage
	hitPoints -= damage;
	// Are we dead?
	if (hitPoints <= 0.0)

function Replace() {
	// If we have a dead barrel then replace ourselves with it!
	if (deadReplacement) {
		var dead : Rigidbody = Instantiate(deadReplacement, GOPos.transform.position, GOPos.transform.rotation);
		// For better effect we assign the same velocity to the exploded barrel
		dead.rigidbody.velocity = rigidbody.velocity;
		dead.angularVelocity = rigidbody.angularVelocity;
	// Destroy ourselves
	Debug.Log("Calling destroy for " + gameObject);

what is the problem you face you need to be brief about your problem and what fix you want

Dont use speech marks to get componenet

GO.GetComponent(ScoreManager); correct

GO.GetComponent("ScoreManager"); wrong


Thanks everyone. Problem was not my destroy script, it was that the dead body that replaces it did not have a destroy script. “DOH!” Now it works perfect. :slight_smile: