Moving part to an object!

How can I maek a part move to another part like how the moveTo() function works is there anny way?

1 Like
oldPart.CFrame = newPart.CFrame

OR

oldPart.Position = newPart.Position

You can use CFrame if you want it to preserve the rotation, otherwise use Position if you only want the position to change

But I ment with the move to part that its going smootly like tweening.

Ahh, you should consider a service like TweenService

local TweenService = game:GetService("TweenService")

local info = TweenInfo.new(1, Enum.EasingStyle.Quad)

local tween = TweenService:Create(oldPart, info, {Position = newPart.Position})
tween:Play()
2 Likes

btw one more question can I make it so this part will follow a part even when its moving like pathfinding but that has lots of problems so I tougth maybe theres a better way

This will require either a while loop or hook upon RunService.Heartbeat, you can move a part towards another part using this operation:

local SPEED = 5

while true do
  local delta = task.wait()
  oldPart.CFrame = CFrame.new(oldPart.Position, newPart.Position)
  oldPart.Position += oldPart.CFrame.LookVector * (SPEED * delta)
end
1 Like

I would recommend using tween service and just tween your original part to the position you want it to go in.