Welcome to the forums.

Although RS_Arm's code does work, there needs to be a way to stop if from following the cursor as that behavior can be very annoying.

Is this for a game?