Detecting if a player is in vr, not working

local VRService = game:GetService("VRService")

local Players = game:GetService("Players")
local localPlayer = Players.LocalPlayer

if VRService.Enabled then
	print(localPlayer.Name.." is using VR!")
else
	print("no vr")
end

I ran this in a local script in StarterPlayerScripts
Keeps erroring with


This is the only thing I’ve been finding to detect if a players in in VR and I’ve literally copy pasted the code so I’m not sure why it’s not working. Anyone know what’s wrong?

It’s giving an error because the property is VREnabled and not Enabled. Also, I’m not sure that it matters, but the documentation uses UserInputService instead of VRService.


After further research I found this. VRService does seem to exist, just the Enabled has to be VREnabled. Thanks

2 Likes

No problem. VRService does exist as seen in the article below, I just wasn’t sure if using the VREnabled property on one service over another made a difference. (In the VREnabled section they use UserInputService in the code sample which is what confused me.)

VRService | Documentation - Roblox Creator Hub

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.