Help making drag to open drawers

I am trying to make a drawer that opens and closes when you hold and move your mouse, but it seems to go wonky for some reason.

I have tried a couple different methods but this is the main one:

(All is done in first person)

function firstClick()
	local origin = workspace.CurrentCamera.CFrame.Position -- Get Position Of Camera
	local vector = (mouse.Hit.Position - origin).Unit 
	-- If its unclear I am trying to get the original direction that the camera looks at and compare it to the current direction
	originalvector = vector
end)

function update() -- Runs Everytime the camera is different from the previous frame
	local origin = workspace.CurrentCamera.CFrame.Position -- Get Position Of Camera
	local vector = (mouse.Hit.Position - origin).Unit 
	-- Getting The Same Thing as earlier
	local difference = (vector - originaldist).Magnitude
	-- Now I have the total change I run into a problem
	-- How do I find the direction that the player looks at because magnitude is always positive?
	-- This is where I am stuck
end)
1 Like