How do I make my player in unity print text.

Ok so I want to be able to make my player print text, First i want to be able to do it with a key input, and then I want to be able to do it when he collides with an A.I player, this is my code so far

using UnityEngine;
using System.Collections;

public class robot : MonoBehaviour
{

public float maxSpeed = 10f;
bool fasingRite = true;

Animator anim;

// Use this for initialization
void Start () 
{
	anim = GetComponent<Animator>();

}

// Update is called once per frame
void FixedUpdate () 


{
	float move = Input.GetAxis ("Horizontal");

	anim.SetFloat ("speed", Mathf.Abs (move));

	rigidbody2D.velocity = new Vector2 (move * maxSpeed, rigidbody2D.velocity.y);

	if (move < 0 &&!fasingRite)
		Flip ();
	else if(move > 0 && fasingRite)
		Flip ();
}

void Flip ()
{
	fasingRite = !fasingRite;
	Vector3 theScale = transform.localScale;
	theScale.x *= -1;
	transform.localScale = theScale;
   
}

}

Pasted from the clone thread the OP created… >:(

What do you mean by “print text”? If you want to make text appear on screen, you just call it from inside the OnGUI() function as detailed here:

If you want to print to the console, you use

Debug.Log("message");
or
print("message");

Also, “function” is not used in C#, it is for UnityScript. In C#, as your script is, you call the OnGUI function like the Start and Update functions (it is typically placed after the Update function:

void OnGUI () {
		if (GUI.Button (Rect (10,10,150,100), "I am a button"))
			print ("You clicked the button!");
	}

Edit: Also², why do you post the same question twice?