Most, practically all, of the time you move a part to an (X, Y, Z) position, and I just want a few lines where you can move part A to part B (By move I mean teleport move as oppose to slide move)
Ok, so if you simply want a brick to teleport, then there are 2 ways to do this.
1. If you already know the coordinates, you can use Vector3.new()
to change the brick's position.
Like this:
local brick = Workspace.Part brick.Position = Vector3.new(numX, numY, numZ) --Fill in the nums with the coordinates of point B
This will change the bricks position to the exact coordinates you put in place of the numX
, numY
, and numZ
.
Alternatively, you could make 2 bricks, declare them as variables, and use the position of one of the bricks. Like this:
--Declaring vars local partA = Workspace.PartA local partB = Workspace.PartB --Doing the teleport partA.Position = partB.Position
Tell me if I misunderstood your question.
You have to move to a position, because "moving to a part" is ambiguous -- do you want to move to the part's surface (where on it)? To that center of the part? Etc.
Probably, you just want to move to the center of the part. In that case, we just use the target part's Position
property instead of constructing a new Vector3
:
movingPart.Position = target.Position -- Or, to keep snaps and NOT stack on top of objects in the way: movingPart.CFrame = CFrame.new( target.Position ) -- Or, to keep snaps and not move out of the way AND use the -- target's orientation (rotation): movingPart.CFrame = target.CFrame