Im new to unity and don't know whats wrong

im trying to make a win condition for my game and i want the character to pickup an object then move somewhere else and when they enter a collider it move to the win screen but it keeps giving me errors. should it be 2 diffrent scripts or can i do it in just one?

using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;

public class Quest : MonoBehaviour
{

    [SerializeField]
    bool showObjective = false;
    [SerializeField]
    Texture objective;
    [SerializeField]
    private int collision;
    public Collider Elevator;

    void Start()
    {
        showObjective = false;
    }

    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "Player" && collision == 0)
            showObjective = true;
    }
    void OnTriggerExit(Collider other)
    {
        if (other.gameObject.tag == "Player")
            showObjective = false;
        collision = 1;
    }
    void OnGUI()
    {
        if (showObjective == true)
            GUI.DrawTexture(new Rect(Screen.width / 1.8f, Screen.height / 1.4f, 178, 178), objective);
    }
    void OnTriggerEnter(Collider Elevator)
        {
            if (Elevator.gameObject.tag == "player" && collision == 1)
            SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);

    }

void Update()
    {
        if (Input.GetButton("Submit") && collision == 1)
        {



            showObjective = true;
        }
        if (Input.GetButtonUp("Submit") && collision == 1)
        {
            showObjective = false;
        }
       
    }
}

In that case, you should fix the errors.

Unfortunately nobody here can read your mind so you are on your own.

This should be quite helpful to you:

If it is a compiler error:

Remember: NOBODY memorizes error codes. The error code is absolutely the least useful part of the error. It serves no purpose at all. Forget the error code. Put it out of your mind.

The complete error message contains everything you need to know to fix the error yourself.

Always start with the FIRST error in the list, as sometimes that error causes or compounds some or all of the subsequent errors.

The important parts of the error message are:

  • the description of the error itself (google this; you are NEVER the first one!)
  • the file it occurred in (critical!)
  • the line number and character position (the two numbers in parentheses)

All of that information is in the actual error message and you must pay attention to it. Learn how to identify it instantly so you don’t have to stop your progress and fiddle around with the forum.

If it is a runtime error:

What is often happening in these cases is one of the following:

  • the code you think is executing is not actually executing at all
  • the code is executing far EARLIER or LATER than you think
  • the code is executing far LESS OFTEN than you think
  • the code is executing far MORE OFTEN than you think
  • the code is executing on another GameObject than you think it is

To help gain more insight into your problem, I recommend liberally sprinkling Debug.Log() statements through your code to display information in realtime.

Doing this should help you answer these types of questions:

  • is this code even running? which parts are running? how often does it run? what order does it run in?
  • what are the values of the variables involved? Are they initialized? Are the values reasonable?
  • are you meeting ALL the requirements to receive callbacks such as triggers / colliders (review the documentation)

Knowing this information will help you reason about the behavior you are seeing.

You can also put in Debug.Break() to pause the Editor when certain interesting pieces of code run, and then study the scene

You could also just display various important quantities in UI Text elements to watch them change as you play the game.

If you are running a mobile device you can also view the console output. Google for how on your particular mobile target.

Here’s an example of putting in a laser-focused Debug.Log() and how that can save you a TON of time wallowing around speculating what might be going wrong:

https://discussions.unity.com/t/839300/3

Beyond that:

How to report your problem productively in the Unity3D forums:

http://plbm.com/?p=220

Hello, @TheOrself welcome to this forum!

As Kurt mention what error is giving you?
Is it in the console? make a screenshot.

So I presume
there is a win collider
when the player enters it…

Is void OnTriggerEnter(Collider Elevator) give you the error?
like:

You’ve got void OnGUI() in there. That seems very, very outdated. For years we’ve been putting buttons on a Canvas instead. The Unity manual says OnGUI still works, but I wonder whether whatever source you’re using is so old it’s got other stuff that’s obsolete.