I am trying to make a seamless teleporter which teleports player from one part to another part with different position and orientation seamlessly.
The orientation works perfectly. But the position is not perfect. It teleports a little bit off, almost opposite of where the player was on the previous platform.
How can I make it perfect?
Here is the script:
script.Parent.MouseClick:Connect(function(plr)
local root = plr.Character.HumanoidRootPart
local tp = workspace.TELEPORT
local tpPos = tp.Position
local pos = (tpPos - workspace.Part.Position)+root.Position -- The problem is here
local rot = (tp.Orientation-workspace.Part.Orientation)+root.Orientation
local cf = CFrame.new(pos) * CFrame.Angles(math.rad(rot.X),math.rad(rot.Y),math.rad(rot.Z))
root.Parent:SetPrimaryPartCFrame(cf)
end)
Any help is appreciated. Thanks!