Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

VR Service detects mobile people as VR?

Asked by 5 years ago
Edited 5 years ago

Hello.
I made a game all about VR. The VR person has their own nametag and it's customized like the character. When a mobile player joined, it changed the VR person to be just like him, he still had control and all, it just changed to be the mobile player. Is there any way to fix this? Thank you!
EDIT: This game is a VR-Hangout type. So other people can play.
LocalScript:

01local VR = game:GetService("VRService")
02local replicatedfirst = game:GetService("ReplicatedFirst")
03local input = game:GetService("UserInputService")
04local event = game.ReplicatedStorage:WaitForChild("SetPosition")
05if VR.VREnabled then
06    game.ReplicatedStorage.LoadCharacter:FireServer()
07    while true do wait()
08        event:FireServer(VR:GetUserCFrame(Enum.UserCFrame.RightHand),VR:GetUserCFrame(Enum.UserCFrame.LeftHand),VR:GetUserCFrame(Enum.UserCFrame.Head))
09    end
10end

Script:

1local headpart = workspace[" "]
2local Event = game.ReplicatedStorage.SetPosition
3Event.OnServerEvent:connect(function(player,right,left,head)
4    headpart.Head.CFrame = head
5    workspace.righthand.CFrame = right
6    workspace.lefthand.CFrame = left
7end)

My camera script (It also has some problems):

01script.Parent:WaitForChild("ScreenGui").Enabled = true
02local camera = workspace.CurrentCamera
03local player = game.Players.LocalPlayer
04local vr = game:GetService("VRService")
05if vr.VREnabled then
06    game.ReplicatedStorage:WaitForChild("SetNametag"):FireServer()
07    print("Starting Camera Code...")
08    repeat wait()
09        camera.CameraType = Enum.CameraType.Scriptable
10    until camera.CameraType == Enum.CameraType.Scriptable
11    camera.CFrame = CFrame.new(0,0,0)
12    print("Finished Camera Code.")
13end
0
A Mobile Players allowed in this VR Game? Tizzel40 243 — 5y
0
Yup ViviTheLuaKing 103 — 5y
0
Well, it's like a VR hangout type game ViviTheLuaKing 103 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago

Well, because the mobile player can be detected as a VR player, then we will add a status for a mobile player by checking.

01local UIS = game:GetService("UserInputService")
02local GuiService = game:GetService("GuiService")
03local VRService = game:GetService("VRService")
04local isMobile = false
05if UIS.TouchEnabled and not UIS.KeyboardEnabled and not UIS.MouseEnabled
06   and not UIS.GamepadEnabled and not GuiService:IsTenFootInterface() then
07    isMobile = true
08end
09---Your code
10if not isMobile and VRService.VREnabled then
11    --Your codes
12end

This will also return laptop with touchable screen true.

More details: Dev Forum

0
Thank you! :) ViviTheLuaKing 103 — 5y
Ad

Answer this question