You can, but you need to pass in the part itself into the function instead of inserting the Position vectors of the part.
This means you are accessing the Part1 and part2 position vectors only once.
local function movePart1ToPart2(part1 : BasePart,part2 : BasePart)
assert(part1:IsA("BasePart"), "Has to be a basepart or inherit it")
assert(part2:IsA("BasePart"), "Has to be a basepart or inherit it")
while true do--loop continuosly for this new part created
--get the direction from part to humanoid root part
local moveDirection = part2.Position - part1.Position
--check if there is a direction to avoid NAN error for .Unit
if moveDirection .Magnitude > 0.01 then
--get the direction with a stud length of one by using .Unit
local unitMovementDirection = moveDirection .Unit
--add it with the part pets current position to make it move towards the character, 1 studs in length because we .Unit the vector
part1.Position = part1.Position + unitMovementDirection
end
wait()
end
end