Creating seamless teleportation?

I am trying to create a seamless teleport. Basically, I’ve made an elevator, but instead of the elevator actually moving up, it’s just gonna teleport the player to the next floors elevator, and then open the doors. So I’m trying to make the teleport unoticeable.

At the moment, this is what I got

local character = player.Character or player.CharacterAdded:Wait()
					
character:MoveTo(teleport.Position)

It all works, teleport is the part inside the floors elevator. However, when you do teleport, your characters facing position, etc. changes randomly. Is there anyway to get them to teleport facing the exact same way to thus create the seamless effect of teleporting

3 Likes

Couldn’t you use CFrame for this?

I believe you could reposition the user and then use CFrame’s lookVector in order to get the orientation the user was facing.

character:MoveTo(teleport.Position*character.PrimaryPart.CFrame.lookVector)

Never tried using looKVector before, so don’t laugh :sweat_smile: but this just teleported me miles away

Ideally for this you should be setting the CFrame of the HumanoidRootPart, rather then MoveTo

You can see this on the Wiki,

CFrame.new(Vector3 pos, Vector3 lookAt)

Therefor you would input input your Vector3 position (What you were using originally to move the character, teleport.Position)

And the lookVector, another Vector3

local character = player.Character or player.CharacterAdded:Wait()
local HumanoidRootPart = character:WaitForChild("HumanoidRootPart")
local lookVector = HumanoidRootPart.CFrame.lookVector

HumanoidRootPart.CFrame = CFrame.new(teleport.Position, lookVector)

It’s also good to mention that MoveTo accepts only one value, a Vector (unless the wiki is outdated)

Parameters

Name Type Default Description
position Vector3 The Position the Model is to be moved to.
1 Like

try character:SetPrimaryPartCFrame(cframe) this way you can make the character face wherever you want.

Same as setting the rootpart cframe.

Not really working. It rotates the player to face a certain way, as well as the player likes glitches into the ground a little bit

com-video-to-gif%20(2)

Ohh, I see what you need. If you want to teleport the character precisely while preserving original orientation just try

character:SetPrimaryPartCFrame(CFrame.new(yourcframehere.Position))

this will teleport you to the position without sometimes putting you at the very top of the structure, and will retain the previous orientation of the character.

May I see the code your using for this?

To fix the ground glitch you can add ~ 2-3 studs or so to the vector.

teleport.Position + Vector3.new(0, 3 ,0)

Still get the same problem. I can see what’s wrong but don’t know how to fix :sweat_smile: basically need to see the players position compared to the teleport part, and then teleport them to the next teleport part in the same position. Atm they just get teleported onto the exact position of the teleport part.

com-video-to-gif%20(3)

Just ignore the X and Z axis.

character:SetPrimaryPartCFrame(CFrame.new(character.HumanoidRootPart.Position.X,yourcframehere.Position.Y,character.HumanoidRootPart.Position.Z))

of course this assumes the elevator is directly above the player :smile:

2 Likes

@ndrwcswll There are so many better ways to doing this.

toObjectSpace

CFrame CFrame:toObjectSpace(CFrame cf)

Description:
Returns a CFrame transformed from World to Object coordinates. Equivalent to CFrame:inverse() * cf
This function supports threading over its arguments, so you can plug in multiple CFrame values and have their transformations returned as a tuple.

1 Like

Here is what I ended up making,

https://gfycat.com/DeadlySparklingAmoeba

local character = player.Character or player.CharacterAdded:Wait()
local currentPlatform = game:GetService("Workspace"):WaitForChild("ElevatorFloor1") -- The floor of the elevator you're currently in.
local goingPlatform = game:GetService("Workspace"):WaitForChild("ElevatorFloor2") -- The floor of the elevator you're going to

local offset = target.CFrame:toObjectSpace(character:WaitForChild("HumanoidRootPart").CFrame)
character:WaitForChild("HumanoidRootPart").CFrame = goingPlatform  * offset
25 Likes