How to make VR Hands Server Sided

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? To Make the VR Hands not only ClientSided but Server Sided also

  2. What is the issue? image

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
Local Script

local UserInputService = game:GetService("UserInputService")
local VRService = game:GetService("VRService")
local CurrentCamera = workspace.CurrentCamera
if VRService.VREnabled == true then
	warn("haha noob nerd you no have VR")
	local ReplicatedStorage = game:GetService("ReplicatedStorage")
	local Events = ReplicatedStorage:WaitForChild("events")
	local Hands = ReplicatedStorage:WaitForChild("oculusHands"):Clone()
	local handL = Hands:WaitForChild("handL")
	local handR = Hands:WaitForChild("handR")
	Hands.Parent = workspace
	handL:SetPrimaryPartCFrame(VRService:GetUserCFrame(Enum.UserCFrame.LeftHand))
	handR:SetPrimaryPartCFrame(VRService:GetUserCFrame(Enum.UserCFrame.RightHand))
	game:GetService("RunService").RenderStepped:Connect(function()
		handL:SetPrimaryPartCFrame((CurrentCamera.CFrame * VRService:GetUserCFrame(Enum.UserCFrame.LeftHand)))
		handR:SetPrimaryPartCFrame((CurrentCamera.CFrame * VRService:GetUserCFrame(Enum.UserCFrame.RightHand)))
		local LMove = (CurrentCamera.CFrame * VRService:GetUserCFrame(Enum.UserCFrame.LeftHand))
		local RMove = (CurrentCamera.CFrame * VRService:GetUserCFrame(Enum.UserCFrame.RightHand))
		game.ReplicatedStorage.events.VRMove:FireServer()
	end)
else
	warn("look at this chad with VR")
end

Script

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local events = ReplicatedStorage:WaitForChild("events")
local oculusHands = ReplicatedStorage:WaitForChild("oculusHands")

events.VRMove.OnServerEvent:Connect(function(LMove, RMove, handR, handL)
	local Rk = oculusHands.handR.handR:Clone()
	local Lk = oculusHands.handL.handL:Clone()
	
	Lk.Parent = workspace
	Rk.Parent = workspace
	
	Lk.CFrame = LMove
	Rk.CFrame = RMove

end)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

6 Likes

You’ll need to also change the cframe on the server.

1 Like

You’re not passing any of the arguments to the server, so the code won’t work.

You also shouldn’t clone the hands every single time you want to update the position, because then you will be creating hundreds of hand clones in each of the previous position. The real hands should exist on the server. The client should see a cloned version of the hands, and have the real hands hidden.

Having a remote fire inside of a render step will very quickly exhaust the remote limit. You should only be updating the server every few passes. You can do this with a count variable and modulus.

Pesudocode:

local count = 0
render step function()
     -- position hands
     count = count + 1
     if count % 5 == 0 then
          replication:Fire()
     end
end

Setting CFrames won’t cause the hands to have physics. And for the server replication, there will be a noticeable stutter. If this is an issue for you, I would suggest BodyMovers, specifically BodyPosition to position hands and BodyGyro to rotate hands.

1 Like

I am confused I did that inimage

1 Like

I meant the primary part & the loop aswell

I am generally new to Scripting and I am really confused what I am doing can you give me a simpler explanation please?