Part follow mouse error

im trying to make a placement system but this happens

it works fine without the camera being locked to a part

code:

game:GetService("RunService").RenderStepped:Connect(function()
	local part = workspace.testblock
	local mouse = plr:GetMouse()
	mouse.TargetFilter = part
	
	part.CFrame = CFrame.new(mouse.Hit.p.X, part.Position.Y, mouse.Hit.p.Z)
end)

The code you posted is perfectly fine. It seems like a different part of your script is causing the error.
(Minor improvements below)

local RunService = game:GetService("RunService")
local Players = game:GetService("Players")

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

local part = workspace:WaitForChild("testblock")
mouse.TargetFilter = part

RunService.RenderStepped:Connect(function()
	if mouse.Target then
		part:PivotTo(CFrame.new(mouse.Hit.Position))
	end
end)

Is there any other scripts involving the part placement? The one you displayed seems fine.

that didnt change anything still does the same glitch when locking the camera to the part (game.Workspace.CurrentCamera.CFrame = game.Workspace.Game.GameCamera.CFrame)

no this is the only script that is moving that part its a localscript

And there’s nothing at all blocking the camera of the first video? No invisible parts?

the part the camera is locked to

This is happening because your camera positioning is mistimed. You need to set your CameraType to Scriptable. Right now your code is fighting the default camera controls. What happens is you set the camera position, the game renders, the default camera takes control, then you check the mouse position. So your mouse position is coming from the default camera position.

nothing changes at all same glitch

edit: nvm it switched to custom when i clicked run