Script
-- //Services
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
-- //Folder
local RemoteEvents = ReplicatedStorage:FindFirstChild("RemoteEvents")
-- //Remotes
local VREnabled = RemoteEvents:FindFirstChild("VREnabled")
-- //Module
local PartModule = require(script:FindFirstChild("PartModule"))
VREnabled.OnServerEvent:Connect(function(player: Player, ...: any)
-- //Character
local character = player.Character or player.CharacterAdded:Wait()
-- //
PartModule:Joints(player, character)
end)
Local Script
-- //Services
local VRService = game:GetService("VRService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Camera = workspace.CurrentCamera
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
-- //Folder
local RemoteEvents = ReplicatedStorage:FindFirstChild("RemoteEvents")
-- //Remotes
local VREnabled = RemoteEvents:FindFirstChild("VREnabled")
-- //Character
local character = script.Parent
-- //BaseParts
local Head = character:FindFirstChild("Head")
local RightArm = character:FindFirstChild("RightArm")
local LeftArm = character:FindFirstChild("LeftArm")
-- //Player
local player = Players:GetPlayerFromCharacter(character)
if VRService.VREnabled then
VREnabled:FireServer()
player.CameraMode = Enum.CameraMode.LockFirstPerson
end
function UpdateCFrame()
-- //Virtual CFrames -- stay here.
local HeadVR = VRService:GetUserCFrame(Enum.UserCFrame.Head)
local LeftVR = VRService:GetUserCFrame(Enum.UserCFrame.LeftHand)
local RightVR = VRService:GetUserCFrame(Enum.UserCFrame.RightHand)
--//
Head.CFrame = Camera.CFrame * HeadVR
RightArm.CFrame = Camera.CFrame * RightVR:ToWorldSpace()
LeftArm.CFrame = Camera.CFrame * LeftVR:ToWorldSpace()
end
VRService.UserCFrameChanged:Connect(UpdateCFrame)
PartModule
local module = {}
function module:Joints(player, character)
-- //Humanoid
local Humanoid = character:FindFirstChild("Humanoid")
-- //
Humanoid.RequiresNeck = false
-- //for loop
for _, Motor6D in ipairs(character:GetDescendants()) do
if Motor6D:IsA("Motor6D") and (string.match(Motor6D.Name, "Shoulder") or string.match(Motor6D.Name, "Neck")) then
Motor6D:Destroy()
end
end
-- //for loop
for _, Part in ipairs(character:GetChildren()) do
if Part:IsA("BasePart") then
Part.CanCollide = true
Part.CollisionGroup = "VirtualReality"
-- //SetNetworkOwner
Part:SetNetworkOwner(player)
end
end
end
return module