I can't figure out the error for this.

So the error I got says, “Assets/CollectPaper.js(40,98): BCE0044: expecting “”, found ‘/r’.”

Here is the script that I used:

#pragma strict
@script RequireComponent ( AudioSource )
var papers : int = 0;
var papersToWin = 5;
var distanceToPaper : float = 2.5;
public var paperPickup : AudioClip;

function Start ()

{

Screen.lockCursor = true;

}

function Update ()
{
if(Input.GetMouseButtonDown (0) || Input.GetKeyDown (KeyCode.E))
{
var ray = Camera.main.ScreenPointToRay(Vector3(Screen.width * 0.5,
Screen.height * 0.5, 0.0));
var hit : RaycastHit;

if(Physics.Raycast(ray, hit, distanceToPaper))
{
if(hit.collider.gameObject.name == "Paper")
{
papers += 1;
audio.PlayClipAtPoint(paperPickup, transform.position);
Destroy(hit.collider.gameObject);
}
}
}
}

function OnGUI ()
{
if(papers < papersToWin)
{
GUI.Box(Rect((Screen.width * 0.5) -60, 10, 120, 25), " " + papers.ToString() + "
papers");
}
else
GUI.Box(Rect((Screen.width/2) - 100, 10, 200, 35), "All Papers Collected!");
}

If you can help me fix this error, that would be much appreciated! Thanks! (I couldn’t find how to fix this myself.)

There you go, sorry, couldn’t find the option the first time.

1 Like

The compiler complains that you made a word wrap in the string. Write line 40 without the word wrap in just one line:

GUI.Box(Rect((Screen.width * 0.5) -60, 10, 120, 25), " " + papers.ToString() + "papers");

or make the word wrap before the "

GUI.Box(Rect((Screen.width * 0.5) -60, 10, 120, 25), " " + papers.ToString() +
"papers");
1 Like

Thank you very much, sir!