Problem with orientation

I’m making a teleport system. It works but however I want make the character orientation to face the orb it is teleporting at. The character’s orientation doesn’t change at all in the code right now. I tried humanoid.MoveDirection but it always stays at Vector3(0,0,0). How would I make the player face the orb it is teleporting at?

Code:

local function LerpChar(Char, Part)
	for i = 0,1,0.05 do
		Char.HumanoidRootPart.CFrame = Char.HumanoidRootPart.CFrame:Lerp(Part.CFrame, i)
		wait(0.05)
	end
end

local function ChangeVisible(Part)
	for _,Orb in pairs(workspace:GetDescendants()) do
		if Orb.Name == "Orb" and Orb ~= Part then
			Orb.Transparency = 0
		elseif Orb == Part then
			Orb.Transparency = 0.8
		end
	end
end

for _,v in pairs(workspace:GetDescendants()) do
	if v:IsA("BasePart") and v.Name == "Orb" then
		local ClickDetector = v.ClickDetector
		ClickDetector.MouseClick:Connect(function(plr)
			local plrChar = plr.Character
			plrChar.HumanoidRootPart.Anchored = true
			LerpChar(plrChar, v)
			ChangeVisible(v)
		end)
	end
end

Explorer:

Add a body gyro to the humanoid root part

BodyGyro.CFrame = CFrame.new(HumanoidRootPart.Position, Orb.Position)

Also make sure to use plenty of force and to disable it afterwards

The HumanoidRootPart has to be anchored for it to teleport. I tried a bodygyro and unanchored the character but it doesn’t work, the character just glitchs and it falls down.

I will try using a weld instead of anchoring the humanoidrootpart and see if that helps.

A quick fix is make our head looks at part, here is a example

  local function LerpChar(Char, Part)
    	Char.Head.CFrame = CFrame.new(Char.Head.Position, Part.Position)
    	for i = 0,1,0.05 do
    		Char.HumanoidRootPart.CFrame = Char.HumanoidRootPart.CFrame:Lerp(Part.CFrame, i)
    		wait(0.05)
    	end
    end
2 Likes

I changed it a little and it worked!

local function LerpChar(Char, Part)
	Char.HumanoidRootPart.CFrame = CFrame.new(Char.HumanoidRootPart.Position, Part.Position)
	for i = 0,1,0.05 do
		Char.HumanoidRootPart.Position = Char.HumanoidRootPart.CFrame.Position:Lerp(Part.Position, i)
		wait(0.05)
	end
end