Roblox vr laser pointer

Im trying to make a vr game but i keep getting an error when i load into the game inside the laser pointer core script gives me an error and the laser pointer is stuck in place. This is the error:

20:08:09.994 CoreGui.RobloxGui.Modules.VR.LaserPointer:885: attempt to index nil with ‘Y’ - Client - LaserPointer:885

and here is my vr script that may be messing with it:

local vrservice = game:GetService("VRService")
local uis = game:GetService("UserInputService")
local rs = game:GetService("RunService")

local plr = game.Players.LocalPlayer
local char = script.Parent
local cam = game.Workspace.CurrentCamera
local headscale = 1
local righthand = char:WaitForChild("RightHand")
local lefthand = char:WaitForChild("LeftHand")
local head = char:WaitForChild("Head")

-- define variables to store the previous position and time of the right hand
local prevRightHandPos = nil
local prevTime = nil

if vrservice.VREnabled == true then
	print(plr.Name.." joined with vr")
	game.StarterGui:SetCore("VRLaserPointerMode", 0)
	game.StarterGui:SetCore("VREnableControllerModels", false)
	vrservice:RecenterUserHeadCFrame()
	cam.HeadScale = headscale

	vrservice.UserCFrameChanged:Connect(function(thing, cframe)
		local RightHandCFrame = vrservice:GetUserCFrame(Enum.UserCFrame.RightHand)
		local LeftHandCFrame = vrservice:GetUserCFrame(Enum.UserCFrame.LeftHand)
		local HeadCFrame = vrservice: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

		-- calculate the speed of the right hand
		local currentRightHandPos = RightHandMathified.Position
		local currentTime = os.clock()
		if prevRightHandPos ~= nil and prevTime ~= nil then
			local speed = (currentRightHandPos - prevRightHandPos).magnitude / (currentTime - prevTime) 
			local editiedspeed = math.floor(speed /50)
			--print("Right hand speed: "..editiedspeed)
			game.Workspace.MainMenu.asd.SurfaceGui.TextLabel.Text = "ArmPower: "..editiedspeed
		end
		prevRightHandPos = currentRightHandPos
		prevTime = currentTime
	end)
	
	rs.RenderStepped:Connect(function()
		cam.HeadLocked = false
		cam.CameraType = Enum.CameraType.Scriptable
		local HeadCFrame = vrservice:GetUserCFrame(Enum.UserCFrame.Head)

		cam.CFrame = CFrame.new(0, 5, 0) * CFrame.new(HeadCFrame.Position) * CFrame.Angles(HeadCFrame:ToEulerAnglesXYZ())
	end)
else
	plr:Kick("No Vr Detected")
end

where is the line of code that is sending the error?

its comming from the laser pointer script and it says line 885 but there is no line 885 and when i click on the error it takes me to line 1.