Teleport to the same position as the old Part

Hello, I’m trying to teleport the player here, but in a specific way.

I don’t want the player to simply be teleported to the middle of the part; I want them to be teleported to the same position they were in.

I don’t know how to explain it, so I made a diagram:
ExplicationSchemaRoblox

1 Like

Okay, I managed to fix my problem.
The script for those who want it:

local TeleportPart1 = script.Parent.TeleportPart1
local Part1 = script.Parent.Part1

TeleportPart1.Touched:Once(function(t)
	if t.Parent:FindFirstChild("Humanoid") then
		local hum = t.Parent:FindFirstChild("HumanoidRootPart")

		local RelativePosition = TeleportPart1.Center.CFrame:toObjectSpace(hum.CFrame) 
		local NextCenterCFrame = Part1.Center.CFrame
		local NewCFrame = NextCenterCFrame * RelativePosition 

		hum.CFrame = NewCFrame
	end
	script.Disabled = true
	wait(1)
	script.Disabled = false
end)

Center is a part placed in the middle of Part1 and TeleportPart1

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.