SOLVED.
Thank you PraetorBlue for helping me out!
I’m trying to make teleporters and I have the base code mostly set up but I’m running into some error issues. Some way to fix the error or make my code better would be very appreciated.
Code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class teleporters : MonoBehaviour
{
public Vector3 teleporterExit;
// Start is called before the first frame update
void Start()
{
teleporterExit = gameObject.Find(“teleportExit”).GetComponent.transform();
}
// Update is called once per frame
void Update()
{
}
public void OnTriggerEnter(Collider other)
{
if(other.gameObject.tag == “TeleporterEntrance”)
{
transform.position = teleporterExit;
}
}
}
Error message:
Assets\teleporters.cs(13,26): error CS0176: Member ‘GameObject.Find(string)’ cannot be accessed with an instance reference; qualify it with a type name instead
gameObject
is a property of your MonoBehaviour which refers to the GameObject your MonoBehaviour is attached to.
GameObject
is the name of the GameObject class.
In order to call a static method such as GameObject.Find(), you must use the class name to call the method. That’s because static methods are not related to a specific instance of a class, they are part of the class itself.
You can tell Find is a static method because it is marked as static in the documentation page: Unity - Scripting API: GameObject.Find
To fix your issue you need to just change gameObject.Find("teleportExit")
to GameObject.Find("teleportExit")
with a capital G.
1 Like
Please use code tags, it’s easier to read and we haven’t got to count the lines to find out the line number 
Probably typo on 13, pretty sure it’s GameObject.Find() not gameObject.Find().
See what happens with that is I have to do instead of .transform and then it gives me this error:
ArgumentException: GetComponent requires that the requested component ‘Vector3’ derives from MonoBehaviour or Component or is an interface.
UnityEngine.GameObject.GetComponent[T] () (at <31d5d65b32ec483292e13e8ae4100b93>:0)
teleporters.Start () (at Assets/teleporters.cs:13)
and this error:
Assets\teleporters.cs(13,26): error CS0029: Cannot implicitly convert type ‘UnityEngine.Transform’ to ‘UnityEngine.Vector3’
A Transform component itself is not of type Vector3. It’s of type Transform. You probably want GetComponent.position.