Getting Parsing error CS8025

I’m getting an error for this teleporting script, and I’m not sure whats wrong. Thanks in advance.

var spawn : Transform;

function OnTriggerEnter(other : Collider) { if (cother.tag == “Player”) { other.transform.position = spawn.position; } }

Oh and I also have a problem with playing sound on collision. I keep getting the “a namespace can only contain types and namespace declarations” error on EVERY script I’ve tried.
This is the one that I’vetried fixing the most:

public AudiClip myClip;

void Start() { audio.clip = myClip; }

void OnTriggerEnter(Collider obj){ if(obj.tag == “Player”){ audio.Play(); } else { audio.Stop(); } }

It just won’t clear and compile. I’m having real trouble with triggers today. Thanks in advance.

Isn’t the problem that it says cother.tag, instead of other.tag?

In the other example, it’s AudioClip, not AudiClip.

1 Like

thanks im a real idiot.

But this didn’t solve the problem. I think it might be spacing or something else. I am a newb at coding in C Sharp so I would really appreciate it if someone formatted them correctly. And for the audio, I’m getting the A namespace can only contain types and namespace declarations.

u say ur new to c# but u have actually given JS script. 0.0

One of your scripts seems to be UnityScript and the other seems to be C#. Also, the scripts are using 3D physics, but you are posting in the 2D section. Anyhow, the C# script should look something like this:

using UnityEngine;
using System.Collections;

public class AudioTest : MonoBehaviour {
    public AudioClip myClip;
    public AudioSource audio;

    void Start()
    {
        audio.clip = myClip;
    }

    void OnTriggerEnter(Collider obj)
    {
        if (obj.tag == "Player")
        {
            audio.Play();
        }
        else
        {
            audio.Stop();
        }
    }
}