Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to put a VR player on a VR team?

Im making my own VR game using nexus's VR model, and im currently trying to put VR users on a VR team, my code was working just fine before but now its not, can someone help? Heres my code:

game.Players.PlayerAdded:Connect(function()
local userInputService = game:GetService("UserInputService")

local isUsingVR = userInputService.VREnabled
if (isUsingVR) then
TeamColor = BrickColor.new("Really blue")
end
end)

1 answer

✓ Accepted answer

Add a RemoteEvent to ReplicatedStorage which is called CheckVR, and Add a local script to the starterplayerscripts with the following code:

game.ReplicatedStorage.CheckVR:FireServer(game:GetService("UserInputService").VREnabled) -- fire the data

In the server script:


game.ReplicatedStorage.CheckVR.OnServerEvent:Connect(function(plr, isVR) -- on server event
       if isVR then -- check if is vr
            plr.TeamColor = BrickColor.new("Really blue") -- set team to VR Team
       end
end)

You cannot use UserInputService on server. If this works, please mark as a solution. Metatable out!

This discussion is preserved as it was. New answers, comments, and votes are closed.