Best method of checking whether a player is in VR mode on the server

I know that there is no server-side API to do this, but what is the best way? Currently the best thing I can think of is have players who are VR send a RemoteEvent to the server which flags that player as VR. The catch is it can only be fired in the first few seconds of joining so a client script will already know what to do but a cheater might not. As you can probably tell, you can get around this system, just not everybody will at first.

So, I’ll repeat, what’s the best method of checking whether a player is in VR on the server? Is there a better method or is this the best?

4 Likes

The way you describe sounds pretty solid. I also must ask, what might an exploiter have to gain from the server identifying them as a VR player?

1 Like

Here’s a way of determining if the player is on VR:

local VRService = game:GetService("VRService")

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

if VRService.Enabled then
    print(localPlayer.Name.." is using VR!")
end
5 Likes

@Dudeguy90539
I’m making a puzzle game with some friends that requires a person to be in VR to help the other people who aren’t in VR get through stuff. If they get flagged as VR it would make the experience unplayable for others. And my other other worry is that even if this vulnerability isn’t discovered for a while, it’s still possible that somebody finds out about it and makes a script that lots of cheaters use to ruin the game.

@aero9497
Thank you, but the question was how to create a method for checking if somebody is in VR on the server side and, yes, I know that it can’t really be done that easily but I’m looking for the best method of doing so.

1 Like

Even so, the exploiter can easily get around this as apparently scripts automatically ran on gametime exist now… Plus, they can just disable the local script and boom bam pow, “antiexploit” gone.

1 Like

I am sorry, but you have absolutely no control over what device the client is using. If they spoof their device type to VR then it is their fault and it probably wouldn’t look best on a computer. Their headset is their device. Their computer is their device. Their mobile is their device. Their console is their device. This stuff can only be handled locally.

1 Like

I’ll repeat again. I already understand that you can’t know for sure if a player is in VR or not but this is only part of what I’m asking. I’m asking if the method that I explained in the original post is a good method and if there are better ones out there.

I’m sorry for misunderstanding. Unfortunately, there is no way for the server to confirm if the client is using VR without communicating through RemoteEvents. The creation of an anti-exploit on the server might be impossible. Keep digging for stuff. You might come up with something. Best of luck!

1 Like

He said he wants on the Server, not Client.

1 Like

One thing that might re assure you is that cheaters most often use exploits and other scripts in order to gain an advantage over other players. If this game doesnt have that kind of pvp style gameplay, there is much less incentive for a player to try an exploit, so even if someone finds a way through, it is unlikely a large amount of people will try to use this and it shouldnt be that big of a problem.

1 Like

Try this :

game.Players.PlayerAdded:Connect(function()
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

end)

I do not have a vr headset so I could not test it but in theory it should work.

Sorry, maybe I didn’t explain this better in the original post because I’ve said it a few times this thread. I do not need to know simply how to check if a player is in VR locally. I’m mainly asking about the method I would use to check if a player is in VR on the server.

3 Likes

I did post a way to check in server that is not a local script that I posted forgot to mention that.

local isUsingVR = userInputService.VREnabled
if (isUsingVR) then
    print("User is using a VR headset!")
else
    print("User is not using a VR headset!")
end
end)

^^ is a server script.

@Baileyeatspizza UserInputService cannot be used on the server, it is a client-side only service. Meaning it can only be used in a LocalScript or in a ModuleScript required by a LocalScript.

4 Likes

Sorry for the bump, but I would like to share my method.

This method will only work if your VR players are not in the control of a character. Like in VR Hands or VR Islands, while normal players have their avatar loaded as usual

  1. Disable CharacterAutoLoads in player settings. We want to be in control of player respawn.
  2. Use RemoteFunction on client.

Yes I know. That is not recommended. I do believe we should make one exception here though. Anyway, once you wrap client invoke in pcall(), what is the worst that could happen? Few indefinitely yielding threads? It would require ridiculous amount of dedicated attacks affect only only one server instance. And I am not even sure if that is possible anyway, due to Roblox internal server safeguards.

--server script
local AreYouVR = Instance.new("RemoteFunction")
AreYouVR.Name = "AreYouVR"
AreYouVR.Parent = game.ReplicatedStorage

local LegitVRplayers = {}
local LegitPlayers = {}

game.Players.PlayerAdded:Connect(function(player)

	player.CharacterAdded:Connect(function(character)
		
		if not LegitPlayers[player] then
			player:Kick("Please do not use exploits!")
		end
		local Humanoid = character:WaitForChild("Humanoid")
		Humanoid.Died:Connect(function()
			task.wait(3)
			player:LoadCharacter()
		end)

	end)

	pcall(function()

  		local vr = AreYouVR:InvokeClient(player)
		if not vr then
			LegitPlayers[player] = true
			player:LoadCharacter()
		else
			LegitVRPlayers[player] = true
		end

	end)

end)

--local script
-- I recommend to put this script in ReplicatedFirst, as we want it to run ASAP
local AreYouVR = game.ReplicatedStorage:WaitForChild("AreYouVR")
local VRService = game:GetService("VRService")

local function OnClientInvoke()
	return VRService.VREnabled
end
AreYouVR.OnClientInvoke = OnClientInvoke

Exploit scenarios:

  • player without VR pretending to be VR - player will not be able to use character.
  • player with VR pretending to be not on VR - you can check LegitVRPlayers table before executing any server sided VR functions.
  • player not returning response to the remote function. Player is unable to use character and vr server sided functions, as neither LegitPlayers nor LegitVRPlayers table is set. There will be a tiny, forever yielding thread on the server, but it is very unlikely that it will affect the game in anyway.

In conclusion:

To be honest, there isn’t really a good solution here. You can never be sure whether player is on VR or not. My suggestion is to develop your game so that either:

  • VR players have no advantage over normal players and vice versa.
  • write a dedicated VR anti exploit script (is player moving too fast? are their hands have impossible reach? etc…)
  • make VR players have different goals and tasks than normal players. For example make your VR players act like bosses or helpers.
3 Likes