With this way right arm folows the cursor even behind of the character. How can i set boundary for limiting arm movement?

local armOffset = character.UpperTorso.CFrame:Inverse() * character.RightUpperArm.CFrame
local armWeld = Instance.new("Weld")
armWeld.Part0 = character.UpperTorso
armWeld.Part1 = character.RightUpperArm
armWeld.Parent = character

RunService.Heartbeat:Connect(function()
	local cframe = CFrame.new(character.UpperTorso.Position, mouse.Hit.Position) * CFrame.Angles(math.pi/2, 0, 0)
	armWeld.C0 = armOffset * character.UpperTorso.CFrame:toObjectSpace(cframe)
end)