Skip to Content

Vector3

Three-component vector type used for positions, sizes, directions and rotations.

Y is the up axis. One unit is one stud.

local spawn = Vector3.new(0, 5, 0)
local inFront = character.Position + character.LookVector * 5
local distance = (part.Position - character.Position).Magnitude
OperatorResult
a + b, a - bComponent-wise addition or subtraction.
a * 2, a / 2Scalar multiplication or division.
a * bComponent-wise multiplication.
a == btrue if every component is equal within a small tolerance.

Constructors

new

Vector3.new(x: number, y: number, z: number): Vector3

Constructs a vector. The constants Vector3.zero and Vector3.one are also available.

Properties

X

vector.X: number

X component. Y and Z are also available.

Magnitude

vector.Magnitude: number

Euclidean length.

Unit

vector.Unit: Vector3

Normalized copy with a magnitude of 1.

Methods

Dot

a:Dot(b: Vector3): number

Returns the dot product of a and b.

Cross

a:Cross(b: Vector3): Vector3

Returns the cross product of a and b.

Lerp

a:Lerp(b: Vector3, amount: number): Vector3

Linearly interpolates from a to b by amount. 0 returns a and 1 returns b.

On this page