Accessing a function from another script

Hi. I’ve struggled to find the answers to these two problems. Primarily, I can’t seem to access a function in another script on another game object. It gives me this error: playerMove.Dead() is inaccessible due to its protection level.

Also, in the same code, enemyAI, I can’t seem to delete an object after instantiation. It gives me this error: Cannot cast from source type to destination type.

CODE:
Player script (The script with the function I am trying to access)

public class playerMove : MonoBehaviour
{
	public float speed;
	public float tilt;
	public ParticleSystem deathParticle;

	void FixedUpdate ()
	{
		float moveHorizontal = Input.GetAxis ("Horizontal");
		float moveVertical = Input.GetAxis ("Vertical");
		
		Vector3 movement = new Vector3 (moveHorizontal, moveVertical, 0.0f);
		rigidbody.velocity = movement * speed;

	}
	void Dead(){
		Application.LoadLevel (Application.loadedLevel);
	}
}

Script with the second error + code trying to access player move’s function

public class enemyAI : MonoBehaviour {

	public bool smartAI = false;
	public int force = 5;
	public float delay = 5;

	public playerMove script;

	// Use this for initialization
	void Start () {

	}
	
	// Update is called once per frame
	void Update () {
		rigidbody.AddForce(0.0f ,0.0f, force * -1);
	}
	void OnTriggerEnter(Collider collider){
		if(collider.tag == "Player"){
			Debug.Log ("We've been hit!");
			script.Dead();
		}
	}
}

using UnityEngine;
using System.Collections;

public class spawnPoint : MonoBehaviour {

private int randomInt;
public float spawnRate;

public Rigidbody enemyPrefab;

// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {
	randomInt = Random.Range (0,950000);
	if(randomInt < 1000){
	GameObject enemy = (GameObject)Instantiate(enemyPrefab, transform.position, transform.rotation);
	Destroy (enemy, 5);
	}
}

}
MOAR CODE
using UnityEngine;
using System.Collections;

public class spawnPoint : MonoBehaviour {

	private int randomInt;
	public float spawnRate;

	public Rigidbody enemyPrefab;

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
		randomInt = Random.Range (0,950000);
		if(randomInt < 1000){
		GameObject enemy = (GameObject)Instantiate(enemyPrefab, transform.position, transform.rotation);
		Destroy (enemy, 5);
		}
	}
}

All variables and methods are private by default in C# (in UnityScript they default to public).
So change a void method to public void if you need to access an instances method externally.
As for your other error, post some code and we’ll see what we can do :slight_smile: