How can I move a part to where the mouse is pointing by 5 studs?

Hello everyone, so here is my code:

local movePart = workspace.MovePart
local wall = workspace.Wall

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

	mouse.TargetFilter = movePart
	if mouse.Target then
		print("There was a target.")
		movePart.Position = mouse.Hit.Position
		movePart.CFrame += movePart.CFrame.LookVector * 1

It’s supposed to move the part where the mouse is pointing and it does that but I want to move it by 5 studs only, not 0 studs which is what it’s doing now. Thanks for the help.

Maybe check the magnitude between the Player and the Mouse Hit Position?

If it’s below 5 studs, the player can move it, if not stop it


if (game.Players.LocalPlayer.Character:FindFirstChild("HumanoidRootPart").Position - Mouse.Hit.Position) < 5 and not (game.Players.LocalPlayer.Character:FindFirstChild("HumanoidRootPart").Position - Mouse.Hit.Position) > 5 then
    -- things

And use RenderStepped instead of Mouse.Move, it’s better.

Thank you, but what I mean is that I want a part to move where the mouse is pointing (so using mouse.Hit) on another part, just not following it smoothly with 0 studs but following the mouse every 5 studs. I hope that makes sense.