Service · inherits Instance
VRService
Service responsible for handling interactions between Roblox and Virtual Reality (VR).
About VRService
VRService is responsible for handling interactions between Roblox and Virtual Reality (VR). Its methods, properties, and events help you provide the best experience for end users seeking to experience Roblox on VR devices.
See VR Guidelines for more information on publishing an experience for VR devices.
Properties 8
AutomaticScaling
: VRScalingAutomatically adjusts scaling in VR to align the player with their avatar.When set to
VRScaling.World,Camera.HeadScaleadjusts so that the scale of the world is seen from the avatar's perspective. A player with a small avatar will perceive the objects around them as larger than a player with a large avatar will.AvatarGestures
: booleanWhen true, a VR player will be able to animate their hands and head using their controllers and headset.When set to true, a VR player will be able to animate their hands and head using their controllers and headset. Set this to
falsefor experiences where VR hand and head tracking conflicts with custom game mechanics, such as bespoke avatar rigs or weapon systems incompatible with IK-driven gestures.This property must be set on the server.
ControllerModels
: VRControllerModelModeControls whether and how the player's VR hand controllers are rendered in the experience.Controls how the models representing the player's VR hand controllers are displayed (
VRControllerModelMode). When set toTransparent, the controller models are shown with transparency; when set toDisabled, the controller models are not rendered.Defaults to
Transparent.FadeOutViewOnCollision
: booleanWhen true, a VR player's view will fade to black when their head collides with an object.When true, a VR player's view fades to black when their head collides with an object. This property prevents players from being able to see through walls while in VR. The default value is true.
GuiInputUserCFrame
: UserCFrameNotReplicatedDescribes whatUserCFrameis responsible for input in VR.This property describes what
UserCFrameis responsible for input in VR. For instance, if a VR headset is responsible, the value of this property will beUserCFrame.Head.To check if Roblox detects any VR devices, which would be responsible for input in VR, you can check the
VREnabledproperty.LaserPointer
: VRLaserPointerModeControls whether and how the VR laser pointer used to interact with the user interface is displayed.Controls the mode of the laser pointer that a VR player uses to point at and interact with the user interface (
VRLaserPointerMode). Set it toDisabledto hide the laser pointer,Pointerto show a single pointer, orDualPointerto show a pointer for each hand.Defaults to
Pointer.ThirdPersonFollowCamEnabled
: booleanReadOnlyNotReplicatedIndicates whether the third-person follow camera is enabled for the VR user.Read-only. Indicates whether the third-person follow camera is enabled for the VR user. Its value mirrors the user's VR comfort setting and updates automatically whenever the user changes that setting, firing a changed signal so that scripts can respond. It cannot be set from a script.
VREnabled
: booleanReadOnlyNotReplicatedDescribes whether the user is using a virtual reality device.This property describes whether the user is using a virtual reality (VR) device.
If a VR device is enabled, you can interact with its location and movement through methods such as
UserInputService.GetUserCFrame. You can also react to VR device movement using theUserInputService.UserCFrameChangedevent.local UserInputService = game:GetService("UserInputService") local isUsingVR = UserInputService.VREnabled if isUsingVR then print("User is using a VR headset!") else print("User is not using a VR headset!") endThis property can only be used in a
LocalScript.See Also
Methods 6
GetTouchpadMode
(pad: VRTouchpad) → VRTouchpadModeReturns the VRTouchpadMode indicating the mode of a specified VRTouchpad.This method returns the
VRTouchpadModeindicating the mode of a specifiedVRTouchpad. The returned mode indicates how the user interacts with their touchpad to play the game.This can also be used alongside the several
UserInputServiceVR methods and events.This method will only work when used in a
LocalScript.GetUserCFrame
(type: UserCFrame) → CFrameReturns a CFrame describing the position & orientation of a specified virtual reality device as an offset from a point in real world space.This method returns a
CFramedescribing the position and orientation of a specified virtual reality (VR) device as an offset from a point in real world space. This method should be used when implementing VR compatibility into a game to obtain and track the movement of a connected VR device.By using the method, developers can implement features such as re-positioning the user's in-game character corresponding to the location of a connected VR device. This can be done by changing the CFrame of the user's in-game character to match the CFrame of the specified VR device using the UserCFrame enum and CFrame value arguments passed by the event.
VRServicealso provides aUserCFrameChangedevent that automatically fires when theCFrameof connected VR device changes, so long it is used in aLocalScript.This method will only work when used in a
LocalScript.GetUserCFrameEnabled
(type: UserCFrame) → booleanReturns true if the specifiedUserCFrameis available to be listened to.This method returns true if the specified
UserCFramevirtual reality device (VR) is available to be listened to. It can be used to determine whether a specified VR device, such asUserCFrame.Head, is connected to the user's game.This can also be used alongside the several
UserInputServiceVR methods and events.This method will only work when used in a
LocalScript.RecenterUserHeadCFrame
() → ()Re-centers theCFrameto the current location of the VR headset being worn by the user.This method re-centers the
CFrameof the user's head to the current location of the VR headset being worn by the user. It can be used to ensure that the user's in-game head is positioned according to the location of the user's VR headset.This behaves identically to
UserInputService.RecenterUserHeadCFrame.This method will only work when used in a
LocalScript.SetTouchpadMode
(pad: VRTouchpad, mode: VRTouchpadMode) → ()Sets the mode of the specifiedVRTouchpadto the specifiedVRTouchpadMode.This method sets the mode of the specified
VRTouchpadto the specifiedVRTouchpadMode. It can be used to change the user's virtual reality (VR) touchpad mode so that the user interacts with the game differently using the touchpad.This can also be used alongside the several
UserInputServiceVR methods and events.This method will only work when used in a
LocalScript.
Events 4
TouchpadModeChanged
VRService.TouchpadModeChanged:Connect(function(pad, mode))Fires if theVRTouchpadModeof aVRTouchpadis changed.This event fires if the
VRTouchpadModeof aVRTouchpadis changed. You can use this event to track the states of VR touchpads connected via the user's client.This event can be used alongside
UserInputServiceservice events and methods.Since this event fires locally, it can only be used in a
LocalScript.UserCFrameChanged
VRService.UserCFrameChanged:Connect(function(type, value))Fires when aUserCFrameis changed.This event fires when a
UserCFrameis changed, for instance when the user moves a connected VR device. It can be used alongsideGetUserCFrame()to track theCFramecoordinates of a VR device, and when it changes/moves. It can also be used alongsideUserInputServiceservice events and methods.Since this event fires locally, it can only be used in a
LocalScript.UserCFrameEnabled
VRService.UserCFrameEnabled:Connect(function(type, enabled))Fires when aUserCFrameis enabled or disabled.This event fires when a
UserCFrameis enabled or disabled. It can be used alongsideGetUserCFrameEnabled()to track whether a specifiedUserCFrameis enabled, and when its state changes. It can also be used alongsideUserInputServiceservice events and methods.Since this event fires locally, it can only be used in a
LocalScript.
VRService also has every member of Instance. Deprecated and Roblox-only members are hidden.
Reference text from the Roblox Creator Documentation, licensed CC BY 4.0, reorganized by rbxtoolshub.com · Studio 0.743.0.7431133.