Why doesn't Destroy work?

I am trying to make it so that in the pause menu you can change your character. I want to destroy the original player. However, this isn’t working. Any ideas? Boom() destroys the object.

#pragma strict

var pause = false;
var RIP;

var prefab : Transform;
var CS : GameObject;
var SS : GameObject;


function Start () {
	transform.position = CS.transform.position;
	
	Instantiate (SS, transform.position, Quaternion.identity);
}

function Update () {

	if (Input.GetKeyUp ("escape")) {
		pause = true;
		Time.timeScale = 0;
		Debug.Log("babaam");
		
	}

}

function OnGUI() {
	
	if (pause) {
		if (GUI.Button(Rect(Screen.width / 2,Screen.height / 2 - 40,100,30),"Play")) {
			
			Time.timeScale = 1;
			pause = false;
			Debug.Log("Clicked the button with text");
			
		}
		
		if (GUI.Button(Rect(Screen.width / 2,Screen.height / 2,100,30),"Switch")) {
				transform.position = CS.transform.position;
				
				Boom();
				Instantiate (prefab, transform.position, Quaternion.identity);
			
			Time.timeScale = 1;
			pause = false;
			Debug.Log("Clicked the button with text");
			
		}
		
	}
		
}

function Boom() {
	RIP = GameObject.Find("player"); 
	Destroy(RIP);
}

So is this script attached to an empty object for just the pause menu and some logic? Not attached to the players you are destroying right?

Yeah the solution is not popping out in any obvious way to me. I would probably call the boom() function at the end of your button press logic, I like to keep things ordered sequentially especially when dealing with functions calls which on occasion the position of them has messed things up for me in the past.

Also you might need to do

RIP = GameObject.Find(“player(Clone)”);

Depending on how you created the original player, but you can see what the name is in Hierarchy.

Not sure if either of those are your problem but that’d be the first think I would check. I also only use C# so maybe I’m missing something else.