Collapse Sidebar


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


Return Type Summary

Code Samples

Simple Character Teleportation

This code sample is a simple teleport script that moves your character 10 studs forwards in the direction you’re currently facing when you press the F key. It does so by getting the current pivot with PVInstance/GetPivot and calling PVInstance|PivotTo to move the character forwards.

-- This code should be placed in a LocalScript under StarterPlayerScripts
local Players = game:GetService("Players")
local ContextActionService = game:GetService("ContextActionService")

local function doTeleport()
	local player = Players.LocalPlayer
	local character = player.Character
	if character and character.Parent then
		-- Move the character 10 studs forwards in the direction they're facing
		local currentPivot = character:GetPivot()
		character:PivotTo(currentPivot * CFrame.new(0, 0, -10))

ContextActionService:BindAction("Teleport", doTeleport, true, Enum.KeyCode.F)