How could I move a player's arm while they are holding a key and reset the arm back while they let go of it

I would like to achieve a simple local script of a player’s arm moving towards their mouse direction (X and Z, not Y) while they are holding a certain key on their keyboard

This is what I currently have down, but it does not work sadly

local uis = game:GetService("UserInputService")
local r = false
local rwasdown = false
uis.InputBegan:Connect(function(i, a)
	if i.KeyCode == Enum.KeyCode.R and a == false then
		r = true
		rwasdown = true
	end
end)
uis.InputEnded:Connect(function(i, a)
	if i.KeyCode == Enum.KeyCode.R and a == false then
		r = false
	end
end)
local plr = game.Players.LocalPlayer
	local chr = plr.Character or plr.CharacterAdded:Wait()
	local mouse = plr:GetMouse()
	local ra = chr:WaitForChild("Right Arm")
	local la = chr:WaitForChild("Left Arm")
	wait(1)
	local pos = ra.Position
while wait() do
	local hp = mouse
	local move1 = hp.X / 250 - 2.5
	local move2 = hp.Y / 250 - .725
	local rpos = ra.Position
	if r == true then
		ra.Position = pos + Vector3.new(move1, 0, move2)
		pos = pos + Vector3.new(move1, 0, move2)
	else
		if rwasdown == true then
			pos = pos - Vector3.new(move1, 0, move2)
			ra.Position = pos
		end
	end
end

Well… does it show any errors?