Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I make a player teleport to the direction they are facing?

I've been thinking about a teleport script to teleport 10 studs to where the player was facing, but couldn't figure out how I would do it. I tried:

local orientation = character.Torso.Orientation
			character.HumanoidRootPart.Position = CFrame.new(character.Humanoid.RootPart.Position + 10, 0, 0)

but then I realized that it would teleport the player only in the X axis, and I don't know how to get the direction they are facing. I'm kinda new to this kinda stuff so I don't know what I'm doing.

1 comment

0

I've been wondering the same thing. I'll be looking around online for the solution and If I find one I'll let you know

2 answers

✓ Accepted answer

You should use CFrame.LookVector. LookVector is the forward-facing direction of a CFrame, or basically the front of a BasePart. (in your terms)

local humanoidRootPart = character.HumanoidRootPart
humanoidRootPart.CFrame = humanoidRootPart.CFrame + humanoidRootPart.CFrame.LookVector * 10 -- teleport the player 10 studs forward
function onTouch(part)
	if part.Parent.Humanoid ~=nil then
		part.Parent:MoveTo(script.Parent.Parent.Tele2.Position)

	end
end
script.Parent.Touched:connect(onTouch)

assuming you place a second part 10 studs right a head of the touched part. However, the direction of player when facing the part will till determine the direction facing when arriving on "Tele2".

This discussion is preserved as it was. New answers, comments, and votes are closed.