Object that follows mouse jitters after moving

I have a union that is supposed to follow the mouse’s position but after moving to the desired position set in the BodyPosition it sometimes jitters.

Inside the union I have a BodyPosition and a BodyGyro. The BodyGyro is meant to maintain the union’s orientation. Its CFrame is modified and is set to: CFrame.Angles(0, 0, math.rad(-90)). Here are the properties of the BodyPosition and the BodyGyro and a few scripts, as well as a clip that shows my problem.

BodyGyro properties:
D = 500
MaxTorque = 400000, 400000, 400000
P = 3000

BodyPosition properties:
D = 250
MaxForce = 40000, 40000, 40000
P = 10000
Position = 10, 0.5, 0

When the player joins the game I set the player as the network owner of the union (named “Striker”). I need to do this because the striker’s movement must be replicated to the server. I am still unsure of exactly what “SetNetworkOwner” does.

game.Players.PlayerAdded:Connect(function(plr)
        	
workspace.Striker:SetNetworkOwner(plr)
        	
end)

(Server Script located in ServerScriptService)

Then, a local script in StarterPlayerScripts will repeatedly get the player’s mouse and get it’s CFrame position. That position is then set to the striker’s BodyPosition so that the striker moves to the mouse’s position.

local runService = game:GetService("RunService")
local mouse = game.Players.LocalPlayer:GetMouse()
local striker = workspace.Striker

runService.RenderStepped:Connect(function()
	
	local mousePos = mouse.Hit.p

	local pos = mousePos
	
	striker.BodyPosition.Position = Vector3.new(pos.X, striker.BodyPosition.Position.Y, pos.Z)
	
end)

(Local Script located in StarterPlayer.StarterPlayerScripts)

The movement of the striker works, but as mentioned earlier, the striker jitters when it moves to the target. Here is a video that shows this jittering motion.

I hope you can help me find the solution to my problem. Thanks in advance.

The jittering is because the “hit position” of the mouse “hit position” is changing based on the object under it (that red thing)

aka: in one step, mouse.hit.p is calculated, and it’s on the grey floor, then the red hat is moved to it, and in a micro-step, hit.p is set to one small point on the top of that red hat…then the red hat is moved to a new point, and that causes hit.p to be on a slightly offset position on the hat, which moves the hat back to that position, etc etc etc ad infinitum.

What you need to do is ignore the parts that you are dragging.
I would recommend using a Raycast (with Ignore list that includes your dragged part), from the viewport, into the 3d world space, instead of using :GetMouse().Hit.p, which I’m pretty sure is technically deprecated anyway?

Hi, thanks for your reply. I understand what’s causing the issue and will look into the solution. Thanks again for your help!