Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How would I teleport something to a part?

Asked by
Mystdar 352 Moderation Voter
9 years ago

So when and event occurs

game.Workspace.part

Will teleport to

game.workspace.part2

1 answer

Log in to vote
2
Answered by 9 years ago

A number of possibilities should be obvious to you.

Every part has a Position. A simple comparison can have your teleport just like that.

game.Workspace.part.Position = game.Workspace.part2.Position

However, this will account for part boundaries and apply accordingly. If you want the exact coordinates to work with - or want the part to be the exact same place the other is - you would use .CFrame instead. CFrame accounts for the Rotation matrices as well. You could simply add a Vector3 value to it to get it where you want.

game.Workspace.part.CFramew = game.Workspace.part2.CFrame
                                   + Vector3.new(0, 4, 0)

Another method you may know of is :MoveTo()

game.Workspace.part:MoveTo(game.Workspace.part2.Position)

You must use position here. You can convert a CFrame to a position by iterating to it with .p

game.Workspace.part:MoveTo(game.Workspace.part2.CFrame.p)

There are probably even more out there, but that's just about all you'd need!

Ad

Answer this question