VRService | Documentation - Roblox Creator Hub (2024)

Show Deprecated

Not Creatable

Service

VRService is responsible for handling interactions between Roblox andVirtual Reality (VR). Its methods, properties, and events help you provide thebest experience for end users seeking to experience Roblox on VR devices.

See VR Guidelines for moreinformation on publishing an experience for VR devices.

Code Samples

VRService

local VRService = game:GetService("VRService")

local part = workspace.Part

local handOffset = VRService:GetUserCFrame(Enum.UserCFrame.LeftHand)

-- Account for headscale

handOffset = handOffset.Rotation + handOffset.Position * workspace.CurrentCamera.HeadScale

part.CFrame = workspace.CurrentCamera.CFrame * handOffset

Summary

Properties

  • AutomaticScaling:Enum.VRScaling

    Read Parallel

    Automatically adjusts scaling in VR to align the player with their avatar.

  • AvatarGestures:bool

    Read Parallel

    When true, a VR player will be able to animate their hands and head usingtheir controllers and headset.

  • FadeOutViewOnCollision:bool

    Read Parallel

    When true, a VR player's view will fade to black when their head collideswith an object.

  • GuiInputUserCFrame:Enum.UserCFrame

    Not Replicated

    Read Parallel

    Describes what Enum.UserCFrame is responsible for input in VR.

  • ThirdPersonFollowCamEnabled:bool

    Read Only

    Not Replicated

    Read Parallel

  • VREnabled:bool

    Read Only

    Not Replicated

    Read Parallel

    Describes whether the user is using a virtual reality device.

View all inherited from Instance

Methods

  • GetTouchpadMode(pad : Enum.VRTouchpad):Enum.VRTouchpadMode

    Returns the VRTouchpadMode indicating the mode of a specified VRTouchpad.

  • GetUserCFrame(type : Enum.UserCFrame):CFrame

    Returns a CFrame describing the position & orientation of a specifiedvirtual reality device as an offset from a point in real world space.

  • GetUserCFrameEnabled(type : Enum.UserCFrame):bool

    Returns true if the specified Enum.UserCFrame is available to belistened to.

  • RecenterUserHeadCFrame():void

    Re-centers the CFrame to the current location of the VR headsetbeing worn by the user.

  • RequestNavigation(cframe : CFrame,inputUserCFrame : Enum.UserCFrame):void

    Requests navigation to the specified CFrame using the specifiedEnum.UserCFrame as the origin for the visualizer parabola.

  • SetTouchpadMode(pad : Enum.VRTouchpad,mode : Enum.VRTouchpadMode):void

    Sets the mode of the specified Enum.VRTouchpad to the specifiedEnum.VRTouchpadMode.

View all inherited from Instance

Events

  • NavigationRequested(cframe : CFrame,inputUserCFrame : Enum.UserCFrame):RBXScriptSignal

    Fired when navigation is requested from VRService.

  • TouchpadModeChanged(pad : Enum.VRTouchpad,mode : Enum.VRTouchpadMode):RBXScriptSignal

    Fires if the Enum.VRTouchpadMode of a Enum.VRTouchpad is changed.

  • UserCFrameChanged(type : Enum.UserCFrame,value : CFrame):RBXScriptSignal

    Fires when a Enum.UserCFrame is changed.

  • UserCFrameEnabled(type : Enum.UserCFrame,enabled : bool):RBXScriptSignal

    Fires when a Enum.UserCFrame is enabled or disabled.

View all inherited from Instance

Properties

AutomaticScaling

Enum.VRScaling

Read Parallel

When set to Enum.VRScaling.World, Camera.HeadScale adjusts sothat the scale of the world is seen from the avatar's perspective. Aplayer with a small avatar will perceive the objects around them as largerthan a player with a large avatar will.

AvatarGestures

bool

Read Parallel

When set to true, a VR player will be able to animate their hands and headusing their controllers and headset.

This property must be set on the server.

FadeOutViewOnCollision

bool

Read Parallel

When true, a VR player's view fades to black when their head collides withan object. This property prevents players from being able to see throughwalls while in VR. The default value is true.

GuiInputUserCFrame

Enum.UserCFrame

Not Replicated

Read Parallel

This property describes what Enum.UserCFrame is responsible for input inVR. For instance, if a VR headset is responsible, the value of thisproperty will be Enum.UserCFrame.Head.

To check if Roblox detects any VR devices, which would be responsible forinput in VR, you can check the VREnabledproperty.

Code Samples

VRService.GuiInputUserCFrame

local VRService = game:GetService("VRService")

if VRService.VREnabled then

print(VRService.GuiInputUserCFrame.Name)

else

print("No VR device detected!")

end

ThirdPersonFollowCamEnabled

bool

Read Only

Not Replicated

Read Parallel

VREnabled

bool

Read Only

Not Replicated

Read Parallel

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 movementthrough methods such as UserInputService:GetUserCFrame(). You canalso react to VR device movement using theUserInputService.UserCFrameChanged event.

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!")

end

This property can only be used in a LocalScript.

See Also

  • Camera.HeadLocked

  • UserInputService:GetUserCFrame()

  • UserInputService.UserCFrameChanged

Code Samples

VR Head Tracking

local UserInputService = game:GetService("UserInputService")

local Players = game:GetService("Players")

local player = Players.LocalPlayer

local character = player.CharacterAdded:Wait()

local head = character:WaitForChild("Head")

local function TrackHead(inputType, value)

if inputType == Enum.UserCFrame.Head then

head.CFrame = value

end

end

if UserInputService.VREnabled then

-- Set the inital CFrame

head.CFrame = UserInputService:GetUserCFrame(Enum.UserCFrame.Head)

-- Track VR headset movement and mirror for character's head

UserInputService.UserCFrameChanged:Connect(TrackHead)

end

View all inherited from Instance

Methods

GetTouchpadMode

Enum.VRTouchpadMode

This method returns the Enum.VRTouchpadMode indicating the mode of aspecified Enum.VRTouchpad. The returned mode indicates how the userinteracts with their touchpad to play the game.

This can also be used alongside the several UserInputService VRmethods and events.

This method will only work when used in a LocalScript.

Parameters

pad: Enum.VRTouchpad

The specified VRTouchpad.


Returns

Enum.VRTouchpadMode

The mode of the specified VRTouchpad.

Code Samples

VRService:GetTouchpadMode

local VRService = game:GetService("VRService")

VRService:GetTouchpadMode(Enum.VRTouchpad.Left)

GetUserCFrame

CFrame

This method returns a CFrame describing the position andorientation of a specified virtual reality (VR) device as an offset from apoint in real world space. This method should be used when implementing VRcompatibility into a game to obtain and track the movement of a connectedVR device.

By using the method, developers can implement features such asre-positioning the user's in-game character corresponding to the locationof a connected VR device. This can be done by changing the CFrame of theuser's in-game character to match the CFrame of the specified VR deviceusing the UserCFrame enum and CFrame value arguments passed by theevent.

VRService also provides aUserCFrameChanged event thatautomatically fires when the CFrame of connected VR devicechanges, so long it is used in a LocalScript.

This method will only work when used in a LocalScript.

Parameters

type: Enum.UserCFrame

The specified UserCFrame.


Returns

CFrame

Code Samples

VRService:GetUserCFrame

local Workspace = game:GetService("Workspace")

local VRService = game:GetService("VRService")

local camera = Workspace.CurrentCamera

local part = script.Parent.Part

local handOffset = VRService:GetUserCFrame(Enum.UserCFrame.LeftHand)

-- Account for headscale

handOffset = handOffset.Rotation + handOffset.Position * camera.HeadScale

part.CFrame = camera.CFrame * handOffset

GetUserCFrameEnabled

bool

This method returns true if the specified Enum.UserCFrame virtualreality device (VR) is available to be listened to. It can be used todetermine whether a specified VR device, such as Enum.UserCFrame.Head,is connected to the user's game.

This can also be used alongside the several UserInputService VRmethods and events.

This method will only work when used in a LocalScript.

Parameters

type: Enum.UserCFrame

The specified type of VR device.


Returns

bool

A boolean indicating whether the specified VR device is enabled(true) or disabled (false).

Code Samples

VRService:GetUserCFrameEnabled

local VRService = game:GetService("VRService")

local isEnabled = VRService:GetUserCFrameEnabled(Enum.UserCFrame.Head)

if isEnabled then

print("VR device is enabled!")

else

print("VR device is disabled!")

end

RecenterUserHeadCFrame

void

This method re-centers the CFrame of the user's head to thecurrent location of the VR headset being worn by the user. It can be usedto ensure that the user's in-game head is positioned according to thelocation of the user's VR headset.

This behaves identically toUserInputService:RecenterUserHeadCFrame().

This method will only work when used in a LocalScript.


Returns

void

Code Samples

VRService:RecenterUserHeadCFrame

local VRService = game:GetService("VRService")

VRService:RecenterUserHeadCFrame()

RequestNavigation

void

This method requests navigation to the specified CFrame usingthe specified Enum.UserCFrame as the origin for the visualizer parabola.It can be used to incorporate virtual reality (VR) into your game byproviding a means to visualize a navigation path from the user's VR deviceto a destination.

VRService has a similar event,NavigationRequested, used to detectsuch requests. This can also be used alongside the severalUserInputService VR methods and events.

This method will only work when used in a LocalScript.

Parameters

cframe: CFrame

The specified CFrame coordinates.

inputUserCFrame: Enum.UserCFrame

The VR device for which the navigation is requested.


Returns

void

Code Samples

VRService:RequestNavigation

local VRService = game:GetService("VRService")

local destination = workspace:FindFirstChild("NavigationDestination")

VRService:RequestNavigation(Enum.UserCFrame.Head, destination.CFrame)

SetTouchpadMode

void

This method sets the mode of the specified Enum.VRTouchpad to thespecified Enum.VRTouchpadMode. It can be used to change the user'svirtual reality (VR) touchpad mode so that the user interacts with thegame differently using the touchpad.

This can also be used alongside the several UserInputService VRmethods and events.

This method will only work when used in a LocalScript.

Parameters

pad: Enum.VRTouchpad

The specified VRTouchpad you want to set the modeof.

mode: Enum.VRTouchpadMode

The mode you want to set the specified VRTouchpadto.


Returns

void

Code Samples

VRService:SetTouchpadMode

local VRService = game:GetService("VRService")

VRService:SetTouchpadMode(Enum.VRTouchpad.Left, Enum.VRTouchpadMode.Touch)

View all inherited from Instance

Events

NavigationRequested

This event fires when navigation is requested from VRService for aspecified Enum.UserCFrame VR device. It fires with a CFramecoordinate and the specified Enum.UserCFrame indicating the devicerequesting the navigation.

This event can be used alongside UserInputService service eventsand methods.

Since this event fires locally, it can only be used in aLocalScript.

Parameters

cframe: CFrame

The requested CFrame coordinates.

inputUserCFrame: Enum.UserCFrame

Indicates the VR device for which navigation is requested.


Code Samples

VRService.NavigationRequested

local VRService = game:GetService("VRService")

VRService.TouchpadModeChanged:Connect(function(cframe, inputUserCFrame)

print(inputUserCFrame.Name .. " made request with CFrame: " .. cframe)

end)

TouchpadModeChanged

This event fires if the Enum.VRTouchpadMode of a Enum.VRTouchpad ischanged. You can use this event to track the states of VR touchpadsconnected via the user's client.

This event can be used alongside UserInputService service eventsand methods.

Since this event fires locally, it can only be used in aLocalScript.

Parameters

pad: Enum.VRTouchpad

The touchpad that changed mode.

mode: Enum.VRTouchpadMode

The new mode.


Code Samples

VRService.TouchpadModeChanged

local VRService = game:GetService("VRService")

VRService.NavigationRequested:Connect(function(pad, mode)

print(pad.Name .. " Touchpad changed to state: " .. mode.Name)

end)

UserCFrameChanged

This event fires when a Enum.UserCFrame is changed, for instance whenthe user moves a connected VR device. It can be used alongsideGetUserCFrame() to track theCFrame coordinates of a VR device, and when it changes/moves.It can also be used alongside UserInputService service events andmethods.

Since this event fires locally, it can only be used in aLocalScript.

Parameters

type: Enum.UserCFrame

The type of VR device that changed.

value: CFrame

The updated CFrame coordinates of the VR device after thechange.


Code Samples

VRService.UserCFrameChanged

local VRService = game:GetService("VRService")

VRService.UserCFrameChanged:Connect(function(userCFrameType, cframeValue)

print(userCFrameType.Name .. " changed. Updated Frame: " .. tostring(cframeValue))

end)

UserCFrameEnabled

This event fires when a Enum.UserCFrame is enabled or disabled. It canbe used alongsideGetUserCFrameEnabled() to trackwhether a specified UserCFrame is enabled, and when itsstate changes. It can also be used alongside UserInputServiceservice events and methods.

Since this event fires locally, it can only be used in aLocalScript.

Parameters

type: Enum.UserCFrame

The UserCFrame getting enabled or disabled.

enabled: bool

A boolean indicating whether the UserCFrame isenabled (true) or disabled (false).


Code Samples

VRService.UserCFrameEnabled

local VRService = game:GetService("VRService")

VRService.UserCFrameEnabled:Connect(function(type, enabled)

if enabled then

print(type.Name .. " got enabled!")

else

print(type.Name .. " got disabled!")

end

end)

View all inherited from Instance

VRService | Documentation - Roblox Creator Hub (2024)

FAQs

What is Roblox Creator Hub? ›

The Creator Hub, available to all Roblox Creators, gives you all the tools and resources you need to learn, manage and grow your content.

What is RunService used for in Roblox? ›

This function runs the game's simulation, running physics and scripts. When the simulation is running, RunService:IsRunning() will return true. However, RunService:IsRunMode() will only return true if the simulation was started using the 'Run' button in Roblox Studio.

What happened to the Roblox creator Nimblz? ›

Nimblz (Also known as Austin Reuschle in real life) was a Roblox game developer and accelerator notable for creating the adventure-comedy game eg, which was featured in the Egg Hunt 2020: Agents of E.G.G. event. His team also developed wait for 4 hours to leave a room. On May 17, 2020, he passed away due to suicide.

What is getservice Roblox Studio? ›

Instance. Returns a service with the class name requested. When called with the name of a service (such as Debris) it will return the instance of that service. If the service does not yet exist it will be created and the new service is returned.

How to get Robux for free? ›

While there is no way to get Robux for free, you can purchase Robux individually, or through a premium subscription. You can also earn Robux by making clothing and accessories for Roblox avatars or by making making pay-to-play games or games with in-game purchases.

Is Roblox safe for kids? ›

The Bottom Line. Roblox is a safe gaming platform for kids when parents take the recommendations from our experts seriously. But like all technology, it comes with risks, so it's best to start conversations about staying safe with your kids as early as possible.

How do I stop RunService on Roblox? ›

This function ends the game's simulation if it is running. The simulation can be started using RunService:Run() or the 'Run' button in Roblox Studio. When the simulation is stopped, RunService:IsRunning() will return false and RunService:IsEdit() will return true.

Should I use GetService Roblox? ›

You should use :GetService() all the time, since services can be renamed by developers or scripts and will cause errors if not implemented correctly. Sometimes you won't have to if you never actually rename your services, but it's a good practice to always use :GetService() just in case something happens.

How fast is stepped Roblox? ›

As Stepped fires every frame, it runs on a variable frequency. This means the rate will vary depending on the performance of the machine. If the game is running at 40 FPS, then Stepped will fire 40 times per second and the step argument will be roughly 1/40th of a second.

How old is nimblz? ›

On May 17, 2020, Nimblz passed away at the age of 21.

What does Fireserver mean in Roblox Studio? ›

void. Fires the OnServerEvent event on the server from one client. Connected events receive the Player argument of the firing client. Since this method is used to communicate from a client to the server, it will only work when used in a LocalScript.

What is force Roblox? ›

Forces are expensive gamepasses that can have many functions. Certain forces can be helpful in combat, while other forces can be used to troll people. Some forces are unobtainable, but there are still many forces in the game.

What is Creator hub? ›

The Creator Hub is the place to find all the tools, tips and insights you need to learn more about your audience, performance and upcoming trends. From here, you can: View your analytics. Understand trends. Create new content.

How does Roblox talent hub work? ›

Talent Hub is a place where creators can find other people to work with, hire someone for their team, or search for jobs related to their skills. Profiles will show a person's Roblox username and avatar, their skill set, and if they're open for work.

Do Roblox creators get Robux? ›

Developers earn extra Robux for simply building an engaging experience. Roblox calculates an Engagement-Based Payout (EBP) based on the share of time a Roblox Premium subscriber spends in your experience, and these payouts happen automatically as a way to reward engaging experiences.

Top Articles
Latest Posts
Article information

Author: Geoffrey Lueilwitz

Last Updated:

Views: 6305

Rating: 5 / 5 (60 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Geoffrey Lueilwitz

Birthday: 1997-03-23

Address: 74183 Thomas Course, Port Micheal, OK 55446-1529

Phone: +13408645881558

Job: Global Representative

Hobby: Sailing, Vehicle restoration, Rowing, Ghost hunting, Scrapbooking, Rugby, Board sports

Introduction: My name is Geoffrey Lueilwitz, I am a zealous, encouraging, sparkling, enchanting, graceful, faithful, nice person who loves writing and wants to share my knowledge and understanding with you.