Skip to content
RustPluginGenerator
CS0103Oxide + Carbon

Fix CS0103: The name 'Vector3' does not exist in the current context (Oxide)

CS0103 means the compiler cannot resolve a name you used at that line, because the type is not imported, the variable is out of scope, or the name is misspelled. Add the correct using directive or fix the identifier, save the file, and Oxide reloads the plugin.

Server console
Error while compiling TeleportBack:
[1] The name 'Vector3' does not exist in the current context at 46:30

Why it happens

In Oxide plugins the most common cause is a missing using UnityEngine; while the code touches engine types such as Vector3, Quaternion or Time. Oxide compiles each .cs file as its own assembly and does not add namespaces for you, so every type must be either in scope through a using directive or written with its full name. The error line and column point at the exact identifier, so at 31:29 means the token in column 29 of line 31 is unknown.

Other frequent triggers: using a variable outside the block where it was declared (for example a transform or a local declared inside an if), a typo in the name (Vetor3, player.userIdString with the wrong case), or calling a static member like Vector3.Distance after the identifier itself failed to resolve. Case matters in C#: vector3 is not Vector3.

How to fix it

  1. Read the line and column in the console message: [1] The name 'Vector3' does not exist in the current context at 31:29.
  2. If the name is a Unity type, add the matching using directive at the top of the file: using UnityEngine; for Vector3, Quaternion, Time, Mathf, TextAnchor.
  3. If it is a variable, check that it is declared before use and inside the same block. Move the declaration up if needed.
  4. Compare the spelling and case with the API: Vector3, BasePlayer, player.userID, player.UserIDString.
  5. Save the file. Oxide recompiles automatically and prints Loaded plugin TeleportBack v1.0.0 by RustPluginGenerator.
  6. If the message repeats, run oxide.reload TeleportBack after the save and read the new error line; a different CS code means you fixed this one.

Before and after

BeforeFails
using System.Collections.Generic;
using Oxide.Core;

namespace Oxide.Plugins
{
    [Info("Teleport Back", "RustPluginGenerator", "1.0.0")]
    [Description("Saves a player's position and teleports them back later")]
    public class TeleportBack : RustPlugin
    {
        private const string PermUse = "teleportback.use";

        private readonly Dictionary<ulong, UnityEngine.Vector3> savedPositions = new Dictionary<ulong, UnityEngine.Vector3>();

        private void Init()
        {
            permission.RegisterPermission(PermUse, this);
        }

        [ChatCommand("savepos")]
        private void CmdSavePos(BasePlayer player, string command, string[] args)
        {
            if (player == null) return;

            if (!permission.UserHasPermission(player.UserIDString, PermUse))
            {
                SendReply(player, "You do not have permission to use this command.");
                return;
            }

            savedPositions[player.userID.Get()] = player.transform.position;
            SendReply(player, "Position saved.");
        }

        [ChatCommand("backpos")]
        private void CmdBackPos(BasePlayer player, string command, string[] args)
        {
            if (player == null) return;

            UnityEngine.Vector3 target;
            if (!savedPositions.TryGetValue(player.userID.Get(), out target))
            {
                SendReply(player, "No saved position yet. Use /savepos first.");
                return;
            }

            float distance = Vector3.Distance(player.transform.position, target);
            player.Teleport(target);
            SendReply(player, "Teleported back, distance was " + distance.ToString("0") + " meters.");
        }
    }
}
AfterFixed
using System.Collections.Generic;
using Oxide.Core;
using UnityEngine;

namespace Oxide.Plugins
{
    [Info("Teleport Back", "RustPluginGenerator", "1.0.0")]
    [Description("Saves a player's position and teleports them back later")]
    public class TeleportBack : RustPlugin
    {
        private const string PermUse = "teleportback.use";

        private readonly Dictionary<ulong, Vector3> savedPositions = new Dictionary<ulong, Vector3>();

        private void Init()
        {
            permission.RegisterPermission(PermUse, this);
        }

        [ChatCommand("savepos")]
        private void CmdSavePos(BasePlayer player, string command, string[] args)
        {
            if (player == null) return;

            if (!permission.UserHasPermission(player.UserIDString, PermUse))
            {
                SendReply(player, "You do not have permission to use this command.");
                return;
            }

            savedPositions[player.userID.Get()] = player.transform.position;
            SendReply(player, "Position saved.");
        }

        [ChatCommand("backpos")]
        private void CmdBackPos(BasePlayer player, string command, string[] args)
        {
            if (player == null) return;

            Vector3 target;
            if (!savedPositions.TryGetValue(player.userID.Get(), out target))
            {
                SendReply(player, "No saved position yet. Use /savepos first.");
                return;
            }

            float distance = Vector3.Distance(player.transform.position, target);
            player.Teleport(target);
            SendReply(player, "Teleported back, distance was " + distance.ToString("0") + " meters.");
        }
    }
}

FAQ

Why does Vector3 fail even though I used it in another plugin?

Each .cs file is compiled on its own. A using directive in one plugin does not carry over to another, so every file that touches Vector3 needs its own using UnityEngine; line.

Can I avoid using directives entirely?

Yes, by writing the fully qualified name, for example UnityEngine.Vector3.Distance(a, b). It compiles, but adding the using directive once keeps the code readable and avoids repeating the namespace in every call.

The line reported is an empty brace. What now?

The column can land on a token the compiler only resolved after a {. Look at the statement just above or after that brace; a missing variable declaration or a misspelled identifier there is the actual cause.

Does Carbon report CS0103 differently?

Carbon prints the compiler error with its own format, often including the source line, but the code CS0103 and the fix are identical: import the namespace or correct the name. Both loaders recompile when you save the file.

Different error?

Paste the full console output and get the cause and a fix in plain English.

Open the error explainer

Skip the debugging

Generated plugins are compiled before you get them, and compiler errors are fixed automatically.

Generate a plugin

2 free plugins a month, no card.

Last updated Oct 26, 2026.

Get plugins that compile first time

Generate