VR hands script

I was trying to make a basic hand that has no fingers and stuff it just goes to the position of the player’s hand as the head is locked to the first person of the player. This is supposed to make it so forever the player’s “Hand” will be right at the position of the Vr controller IDK why this won’t work if you could help that would be great!

-- local UserInputService = game:GetService("UserInputService")
local VRService = game:GetService("VRService")

if VRService.VREnabled == true then
	while wait() do
	local headCFrame = UserInputService:GetUserCFrame(Enum.UserCFrame.LeftHand)
	local Player = game.Players.LocalPlayer.Character
	
	
	game.Workspace.Part.CFrame = VRService:GetUserCFrame(Enum.UserCFrame.LeftHand)
	end
end
4 Likes

belongs in #help-and-feedback:scripting-support, code review is if you have a working script and want to make it more efficient

3 Likes

It wont go to the right position you need to do something like this

3 Likes

Lets clean this up. First of all, while wait() do is terrible practice. We have RunService for a reason. Heres a fix:

-- local UserInputService = game:GetService("UserInputService")
local VRService = game:GetService("VRService")

if VRService.VREnabled == true then
	game:GetService("RunService").RenderStepped:Connect(function()
       local armCframe = UserInputService:GetUserCFrame(Enum.UserCFrame.LeftHand)
	   local character = game.Players.LocalPlayer.Character
	
	
	   game.Workspace.Part.CFrame = VRService:GetUserCFrame(Enum.UserCFrame.LeftHand)
    end)
end
2 Likes