PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

VREnabled

UserInputService

bool

The VREnabled property indicates whether the user is using a virtual reality (VR) headset. It becomes true if the user is using a VR headset, and false if the user is not using a VR headset.

If a VR headset is enabled, you can interact with it’s location and movement through functions such as UserInputService/GetUserCFrame and UserInputService/RecenterUserHeadCFrame. You can also react to VR headset position changes using the UserInputService/UserCFrameChanged event.

Since UserInputService only runs client-side, this property will only work when used in a LocalScript.


Code Samples


UserInputService.VREnabled

This example prints “User is using a VR headset!” if the VREnabled property is true and “User is not using a VR headset!” is the VREnabled property is false.

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