PVInstance

Show Deprecated
Not Creatable
Not Browsable

A PVInstance ("Position Velocity Instance") is an abstract class that cannot be created. It is the base for all objects that have a physical location in the world, specifically BaseParts and Models.

Summary

Properties

NOT REPLICATED
NOT SCRIPTABLE

Editor-only property used to rotate the object around its pivot. Scripts must use PVInstance:PivotTo() instead.

NOT REPLICATED
NOT SCRIPTABLE

Editor-only property used to move the object. Scripts must use PVInstance:PivotTo() instead.

NOT REPLICATED
NOT SCRIPTABLE
NOT REPLICATED
NOT SCRIPTABLE

Editor-only property to set the orientation of the pivot relative to a part. Scripts must use BasePart.PivotOffset instead.

NOT REPLICATED
NOT SCRIPTABLE

Editor-only property to set the position of the pivot relative to a part. Scripts must use BasePart.PivotOffset instead.

NOT REPLICATED
NOT SCRIPTABLE

Events

Methods


Gets the pivot of a PVInstance.

PivotTo(targetCFrame: CFrame): void  

Transforms the PVInstance along with all of its descendant PVInstances such that the pivot is now located at the specified CFrame.

Properties

Origin

Not Replicated
Not Scriptable

Origin Orientation

Not Replicated
Not Scriptable

Editor-only property used to rotate the object around its pivot. Scripts must use PVInstance:PivotTo() instead.

Origin Position

Not Replicated
Not Scriptable

Editor-only property used to move the object. Scripts must use PVInstance:PivotTo() instead.

Pivot Offset

Not Replicated
Not Scriptable

Pivot Offset Orientation

Not Replicated
Not Scriptable

Editor-only property to set the orientation of the pivot relative to a part. Scripts must use BasePart.PivotOffset instead.

Pivot Offset Position

Not Replicated
Not Scriptable

Editor-only property to set the position of the pivot relative to a part. Scripts must use BasePart.PivotOffset instead.

Events

Methods

GetPivot

This function gets the pivot of a PVInstance. This is often used with PVInstance:PivotTo() to move a model.

Models and BaseParts are both PVInstances ("Position Velocity Instances") and so both have this function.


Returns

Code Samples

Simple Character Teleportation

1-- This code should be placed in a LocalScript under StarterPlayerScripts
2local Players = game:GetService("Players")
3local ContextActionService = game:GetService("ContextActionService")
4
5local player = Players.LocalPlayer
6
7local function doTeleport(_actionName, inputState, _inputObject)
8 local character = player.Character
9 if character and character.Parent and inputState == Enum.UserInputState.Begin then
10 -- Move the character 10 studs forwards in the direction they're facing
11 local currentPivot = character:GetPivot()
12 character:PivotTo(currentPivot * CFrame.new(0, 0, -10))
13 end
14end
15
16ContextActionService:BindAction("Teleport", doTeleport, true, Enum.KeyCode.F)

PivotTo

void

Transforms the PVInstance along with all of its descendant PVInstances such that the pivot is now located at the specified CFrame. This is the primary function that should be used to move Models via scripting.

BaseParts are moved in this way by having their CFrame transformed by the necessary offset. Models are moved in this way by having their Model.WorldPivot transformed by the necessary offset.

Note that for efficiency purposes, Instance.Changed events are not fired for Position and Orientation of BaseParts moved in this way; they are only fired for CFrame.

When calling PivotTo on Models, the offsets of the descendant parts and models are cached, such that subsequent calls to PivotTo on the same model do not accumulate floating point drift between the parts making up the model.

Models and BaseParts are both PVInstances ("Position Velocity Instances") and so both have this function.

Parameters

targetCFrame: CFrame

The CFrame that the PVInstance pivot should equal after moving it.


Returns

void

Code Samples

Simple Character Teleportation

1-- This code should be placed in a LocalScript under StarterPlayerScripts
2local Players = game:GetService("Players")
3local ContextActionService = game:GetService("ContextActionService")
4
5local player = Players.LocalPlayer
6
7local function doTeleport(_actionName, inputState, _inputObject)
8 local character = player.Character
9 if character and character.Parent and inputState == Enum.UserInputState.Begin then
10 -- Move the character 10 studs forwards in the direction they're facing
11 local currentPivot = character:GetPivot()
12 character:PivotTo(currentPivot * CFrame.new(0, 0, -10))
13 end
14end
15
16ContextActionService:BindAction("Teleport", doTeleport, true, Enum.KeyCode.F)