-
What do you want to achieve? VR hands kinda thing
-
What is the issue? i’m making a vr game, but cloning a model from replicated storage is leaving the vital parts out. eg: LeftHand, RightHand, Head
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub? I tried redoing the model, rewrite the script itself. yet it still doesnt work
local UIS = game:GetService("UserInputService")
local VRS = game:GetService("VRService")
local RS = game:GetService("ReplicatedStorage")
local update = RS.Event:WaitForChild("VRUpdate")
local Run = game:GetService("RunService")
local plrparts
local RightHand
local LeftHand
local Head
--setup--
update.OnServerEvent:Connect(function(plr, thing, value1, value2, value3)
if thing == "Joined" then
local plrparts = RS:WaitForChild("PlrParts"):Clone()
RightHand = plrparts:WaitForChild("RightHand")
LeftHand = plrparts:WaitForChild("LeftHand")
Head = plrparts:WaitForChild("Head")
for i,v in pairs(plr.Character:GetChildren()) do
if v:IsA("Accessory") then
local clone = v:Clone()
local weld = Instance.new("Weld")
for _,x in pairs(clone.Handle:GetChildren()) do
if x:IsA("Attachment") then
weld.Part0 = clone.Handle
weld.Part1 = Head
weld.C0 = x.CFrame
weld.C1= Head:FindFirstChild(x.Name).CFrame
elseif x:IsA("Weld") then
x:Destroy()
end
end
clone.Parent = plrparts
weld.Parent = clone
end
end
Head.face.Texture = plr.Character.Head.face.Texture
plrparts.Name = plr.Name.."'s Parts"
plrparts.Parent = game.Workspace
update:FireClient(plr, plrparts)
elseif thing == "PlayerCFrame" then
-- updating hands --
RightHand.CFrame = value1
LeftHand.CFrame = value2
Head.CFrame = value3
end
end)``` This is the server replication.
```local UIS = game:GetService("UserInputService")
local VRS = game:GetService("VRService")
local RS = game:GetService("ReplicatedStorage")
local Run = game:GetService("RunService")
local SG = game:GetService("StarterGui")
local plr = game.Players.LocalPlayer
local char = script.Parent
local Cam = game.Workspace.CurrentCamera
local update = RS.Event:WaitForChild("VRUpdate")
local HeadScale = 1
local timer = 0
-- VR Code --
if VRS.VREnabled == true then
plr.CharacterAppearanceLoaded:Wait()
update:FireServer("Joined", nil, nil, nil)
print(plr.Name.."has joined in VR")
local serverplrparts = update.OnClientEvent:Wait()
local plrparts = serverplrparts:Clone()
print(plrparts, plrparts:GetChildren())
plrparts.Parent = game.Workspace
serverplrparts:Destroy()
local RightHand = plrparts:WaitForChild("RightHand")
local LeftHand = plrparts:WaitForChild("LeftHand")
local Head = plrparts:WaitForChild("Head")
SG:SetCore("VRLaserPointerMode" , 0)
SG:SetCore("VREnableControllerModels" , false )
VRS:RecenterUserHeadCFrame()
Cam.HeadScale = HeadScale
-- Controllers --
VRS.UserCFrameChanged:Connect(function()
local RightHandCFrame = VRS:GetUserCFrame(Enum.UserCFrame.RightHand)
local LeftHandCFrame = VRS:GetUserCFrame(Enum.UserCFrame.LeftHand)
local HeadCFrame = VRS:GetUserCFrame(Enum.UserCFrame.Head)
local RightHandMathified = CFrame.new(Cam.CFrame.Position) * CFrame.new((RightHandCFrame.p-HeadCFrame.Position)*HeadScale) * CFrame.fromEulerAnglesXYZ(RightHandCFrame:ToEulerAnglesXYZ())
local LeftHandMathified = CFrame.new(Cam.CFrame.Position) * CFrame.new((LeftHandCFrame.p-HeadCFrame.Position)*HeadScale) * CFrame.fromEulerAnglesXYZ(LeftHandCFrame:ToEulerAnglesXYZ())
local HeadMathified = Cam.CFrame
RightHand.CFrame = RightHandMathified
LeftHand.CFrame = LeftHandMathified
Head.CFrame = HeadMathified
update:FireServer("PlayerCFrame", RightHandMathified, LeftHandMathified, HeadMathified)
end)
-- Camera --
Run.RenderStepped:Connect(function()
Cam.HeadLocked = false
Cam.CameraType = Enum.CameraType.Scriptable
local HeadCFrame = VRS:GetUserCFrame(Enum.UserCFrame.Head)
Cam.CFrame = CFrame.new(0, 6, 0) * CFrame.new(HeadCFrame.Position) * CFrame.Angles(HeadCFrame:ToEulerAnglesXYZ()) --offset for cam
end)
end``` this is the client replication. Please help!